Commit 19f9f414 by Xinyi He Committed by Commit Bot

Vulkan: Textures incorrect on Android maps with Vulkan Backend

The issue was fixed, but adding a regression test to avoid it again. glMemoryBarrier inserts a memory barrier and breaks the submission order, which causes the copyBufferToImage happens before copyImageToBuffer and image corruption. This test fails on commit 052167bc, and can pass on the latest build. Bug: angleproject:4074 Change-Id: Icc42dd7b2ba167815b223085ce933682654ce760 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1943848 Commit-Queue: Ian Elliott <ianelliott@google.com> Reviewed-by: 's avatarIan Elliott <ianelliott@google.com>
parent 8784a928
...@@ -390,6 +390,20 @@ void main() ...@@ -390,6 +390,20 @@ void main()
GLuint mCubeProgram; GLuint mCubeProgram;
}; };
class MipmapTestES31 : public BaseMipmapTest
{
protected:
MipmapTestES31()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
};
// This test uses init data for the first three levels of the texture. It passes the level 0 data // This test uses init data for the first three levels of the texture. It passes the level 0 data
// in, then renders, then level 1, then renders, etc. This ensures that renderers using the zero LOD // in, then renders, then level 1, then renders, etc. This ensures that renderers using the zero LOD
// workaround (e.g. D3D11 FL9_3) correctly pass init data to the mipmapped texture, even if the the // workaround (e.g. D3D11 FL9_3) correctly pass init data to the mipmapped texture, even if the the
...@@ -1244,7 +1258,71 @@ TEST_P(MipmapTestES3, BaseLevelTextureBug) ...@@ -1244,7 +1258,71 @@ TEST_P(MipmapTestES3, BaseLevelTextureBug)
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red); EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
} }
TEST_P(MipmapTestES31, MipmapWithMemoryBarrier)
{
std::vector<GLColor> pixelsRed(getWindowWidth() * getWindowHeight(), GLColor::red);
std::vector<GLColor> pixelsGreen(getWindowWidth() * getWindowHeight() / 4, GLColor::green);
constexpr char kVS[] = R"(#version 300 es
precision highp float;
in vec4 position;
out vec2 texcoord;
void main()
{
gl_Position = vec4(position.xy, 0.0, 1.0);
texcoord = (position.xy * 0.5) + 0.5;
})";
constexpr char kFS[] = R"(#version 300 es
precision highp float;
uniform highp sampler2D tex;
in vec2 texcoord;
out vec4 out_FragColor;
void main()
{
out_FragColor = texture(tex, texcoord);
})";
ANGLE_GL_PROGRAM(m2DProgram, kVS, kFS);
glUseProgram(m2DProgram);
// Create a texture with red and enable the mipmap
GLTexture texture;
glBindTexture(GL_TEXTURE_2D, texture);
// Fill level 0 with red
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), 0, GL_RGBA,
GL_UNSIGNED_BYTE, pixelsRed.data());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
EXPECT_GL_NO_ERROR();
glGenerateMipmap(GL_TEXTURE_2D);
ASSERT_GL_NO_ERROR();
// level 2 is red
clearAndDrawQuad(m2DProgram.get(), getWindowWidth() / 4, getWindowHeight() / 4);
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 8, getWindowHeight() / 8, GLColor::red);
// Clear the level 1 to green
glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, getWindowWidth() / 2, getWindowHeight() / 2, GL_RGBA,
GL_UNSIGNED_BYTE, pixelsGreen.data());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
EXPECT_GL_NO_ERROR();
glGenerateMipmap(GL_TEXTURE_2D);
ASSERT_GL_NO_ERROR();
// Insert a memory barrier, then it will break the graph node submission order.
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
// level 0 is red
clearAndDrawQuad(m2DProgram.get(), getWindowWidth(), getWindowHeight());
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 2, getWindowHeight() / 2, GLColor::red);
// Draw using level 2. It should be set to green by GenerateMipmap.
clearAndDrawQuad(m2DProgram.get(), getWindowWidth() / 4, getWindowHeight() / 4);
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 8, getWindowHeight() / 8, GLColor::green);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these // Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against. // tests should be run against.
ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(MipmapTest); ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(MipmapTest);
ANGLE_INSTANTIATE_TEST_ES3(MipmapTestES3); ANGLE_INSTANTIATE_TEST_ES3(MipmapTestES3);
ANGLE_INSTANTIATE_TEST_ES31(MipmapTestES31);
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