Commit ecf2956d by Charlie Lao Committed by Angle LUCI CQ

Vulkan: Convert web_gl.fuzz545ImmutableTexRenderFeedback to gl_test

Bug: chromium:1212206 Change-Id: I4b87906a9e877da12d64e39bfe54b9b7cec409a9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2912928Reviewed-by: 's avatarIan Elliott <ianelliott@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
parent e3dd7161
...@@ -4242,6 +4242,137 @@ TEST_P(Texture2DBaseMaxTestES3, RedefineIncompatibleLevelBeyondMaxLevel) ...@@ -4242,6 +4242,137 @@ TEST_P(Texture2DBaseMaxTestES3, RedefineIncompatibleLevelBeyondMaxLevel)
} }
} }
// Port test from web_gl/conformance2/textures/misc/fuzz-545-immutable-tex-render-feedback.html.
// What this try to do is create a renderer feedback loop and ensure it is not crashing.
TEST_P(Texture2DBaseMaxTestES3, Fuzz545ImmutableTexRenderFeedback)
{
// http://crbug.com/1212206
ANGLE_SKIP_TEST_IF(IsVulkan() || IsMetal());
ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Texture2D(), essl1_shaders::fs::Texture2D());
constexpr uint32_t MIPS = 3;
constexpr uint32_t SIZE = 10;
GLTexture immutTex;
glBindTexture(GL_TEXTURE_2D, immutTex);
glTexStorage2D(GL_TEXTURE_2D, MIPS, GL_RGBA8, SIZE, SIZE);
GLTexture mutTex;
glBindTexture(GL_TEXTURE_2D, mutTex);
for (uint32_t mip = 0; mip < MIPS; mip++)
{
const uint32_t size = SIZE >> mip;
glTexImage2D(GL_TEXTURE_2D, mip, GL_RGBA8, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
}
constexpr GLenum MAG_FILTERS[] = {GL_LINEAR, GL_NEAREST};
constexpr GLenum MIN_FILTERS[] = {
GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST,
GL_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_NEAREST};
GLFramebuffer fbo;
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
const GLuint texs[] = {immutTex, mutTex};
for (const GLuint tex : texs)
{
glBindTexture(GL_TEXTURE_2D, tex);
for (GLuint level_prime_base = 0; level_prime_base < (MIPS + 1); level_prime_base++)
{ // `level_base` in GLES
// ES 3.0.6 p150
GLuint _level_base = level_prime_base;
if (tex == immutTex)
{
_level_base = std::min(_level_base, MIPS - 1);
}
const GLuint level_base = _level_base;
for (GLuint _level_prime_max = (level_prime_base - 1); _level_prime_max < (MIPS + 2);
_level_prime_max++)
{ // `q` in GLES
if (_level_prime_max < 0)
continue;
if (_level_prime_max == (MIPS + 1))
{
_level_prime_max = 10000; // This is the default, after all!
}
const GLuint level_prime_max = _level_prime_max;
// ES 3.0.6 p150
GLuint _level_max = level_prime_max;
if (tex == immutTex)
{
_level_max = std::min(std::max(level_base, level_prime_max), MIPS - 1);
}
const GLuint level_max = _level_max;
const GLuint p = std::floor((float)std::log2(SIZE)) + level_base;
const GLuint q = std::min(p, level_max);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, level_prime_base);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level_prime_max);
const bool mipComplete = (q <= MIPS - 1);
for (const GLenum minFilter : MIN_FILTERS)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter);
for (const GLenum magFilter : MAG_FILTERS)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter);
for (GLuint dstMip = 0; dstMip < (MIPS + 1); dstMip++)
{
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, tex, dstMip);
// ES3.0 p213-214
bool fbComplete = true;
// * "The width and height of `image` are non-zero"
fbComplete &= (0 <= dstMip && dstMip <= MIPS - 1);
if (tex != immutTex)
{ // "...does not name an immutable-format texture..."
// * "...the value of [level] must be in the range `[level_base,
// q]`"
fbComplete &= (level_base <= dstMip && dstMip <= q);
// * "...the value of [level] is not `level_base`, then the texture
// must be mipmap complete"
if (dstMip != level_base)
{
fbComplete &= mipComplete;
}
}
// -
GLenum expectError = 0;
GLenum expectStatus = GL_FRAMEBUFFER_COMPLETE;
if (!fbComplete)
{
expectStatus = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
expectError = GL_INVALID_FRAMEBUFFER_OPERATION;
}
// -
EXPECT_GLENUM_EQ(expectStatus,
glCheckFramebufferStatus(GL_FRAMEBUFFER));
drawQuad(program, essl1_shaders::PositionAttrib(), 0.5, 1.0f, true);
EXPECT_EQ(expectError, glGetError());
}
}
}
}
}
}
}
// Test to check that texture completeness is determined correctly when the texture base level is // Test to check that texture completeness is determined correctly when the texture base level is
// greater than 0, and also that level 0 is not sampled when base level is greater than 0. // greater than 0, and also that level 0 is not sampled when base level is greater than 0.
TEST_P(Texture2DTestES3, DrawWithBaseLevel1) TEST_P(Texture2DTestES3, DrawWithBaseLevel1)
......
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