Commit 3c4d7ab0 by Antonio Maiorano Committed by Commit Bot

Fix copy subtexture to GL_RGB9_E5 in ANGLE/VK

When copying via glTexSubImage2D to a non-renderable format, GL_RGB9_E5, ANGLE's TextureVk::copySubTextureImpl will use the read-back and copy method. This path was ignoring the source offset in the source area computation. Fixes the following WebGL tests: conformance2/textures/canvas_sub_rectangle/tex-2d-rgb9_e5-rgb-float.html conformance2/textures/canvas_sub_rectangle/tex-2d-rgb9_e5-rgb-half_float.html Bug: b/157744725 Change-Id: I714f8d3b8f1490edab5e7578445e9623215ce229 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2225611Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
parent fcd3140a
......@@ -526,7 +526,7 @@ angle::Result TextureVk::copySubTextureImpl(ContextVk *contextVk,
// Read back the requested region of the source texture
uint8_t *sourceData = nullptr;
gl::Box area(0, 0, 0, sourceArea.width, sourceArea.height, 1);
gl::Box area(sourceArea.x, sourceArea.y, 0, sourceArea.width, sourceArea.height, 1);
ANGLE_TRY(
source->copyImageDataToBufferAndGetData(contextVk, sourceLevel, 1, area, &sourceData));
......
......@@ -2044,6 +2044,94 @@ TEST_P(CopyTextureTestES3, ES3UintFormats)
GL_UNSIGNED_BYTE, false, false, true, GLColor32U(240, 0, 0, 1));
}
// Test that using an offset in CopySubTexture works correctly for non-renderable float targets
TEST_P(CopyTextureTestES3, CopySubTextureOffsetNonRenderableFloat)
{
if (!checkExtensions())
{
return;
}
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_color_buffer_float"));
auto testOutput = [this](GLuint texture, const GLColor32F &expectedColor) {
constexpr char kVS[] =
"#version 300 es\n"
"in vec4 position;\n"
"out vec2 texcoord;\n"
"void main()\n"
"{\n"
" gl_Position = vec4(position.xy, 0.0, 1.0);\n"
" texcoord = (position.xy * 0.5) + 0.5;\n"
"}\n";
constexpr char kFS[] =
"#version 300 es\n"
"precision mediump float;\n"
"uniform sampler2D tex;\n"
"in vec2 texcoord;\n"
"out vec4 color;\n"
"void main()\n"
"{\n"
" color = texture(tex, texcoord);\n"
"}\n";
ANGLE_GL_PROGRAM(program, kVS, kFS);
glUseProgram(program);
GLRenderbuffer rbo;
glBindRenderbuffer(GL_RENDERBUFFER, rbo);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, 1, 1);
GLFramebuffer fbo;
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glUniform1i(glGetUniformLocation(program.get(), "tex"), 0);
drawQuad(program, "position", 0.5f, 1.0f, true);
EXPECT_PIXEL_COLOR32F_NEAR(0, 0, expectedColor, 0.05);
};
auto testCopy = [this, testOutput](GLenum destInternalFormat, GLenum destFormat,
GLenum destType) {
GLColor rgbaPixels[4 * 4] = {GLColor::red, GLColor::green, GLColor::blue, GLColor::black};
glBindTexture(GL_TEXTURE_2D, mTextures[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels);
GLTexture destTexture;
glBindTexture(GL_TEXTURE_2D, destTexture);
glTexImage2D(GL_TEXTURE_2D, 0, destInternalFormat, 1, 1, 0, destFormat, destType, nullptr);
glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, destTexture, 0, 0, 0, 0, 0, 1, 1,
false, false, false);
EXPECT_GL_NO_ERROR();
testOutput(destTexture, kFloatRed);
glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, destTexture, 0, 0, 0, 1, 0, 1, 1,
false, false, false);
EXPECT_GL_NO_ERROR();
testOutput(destTexture, kFloatGreen);
glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, destTexture, 0, 0, 0, 0, 1, 1, 1,
false, false, false);
EXPECT_GL_NO_ERROR();
testOutput(destTexture, kFloatBlue);
glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, destTexture, 0, 0, 0, 1, 1, 1, 1,
false, false, false);
EXPECT_GL_NO_ERROR();
testOutput(destTexture, kFloatBlack);
};
testCopy(GL_RGB9_E5, GL_RGB, GL_FLOAT);
}
#ifdef Bool
// X11 craziness.
# undef Bool
......
......@@ -142,6 +142,7 @@ struct GLColor32F
GLfloat R, G, B, A;
};
static constexpr GLColor32F kFloatBlack = {0.0f, 0.0f, 0.0f, 1.0f};
static constexpr GLColor32F kFloatRed = {1.0f, 0.0f, 0.0f, 1.0f};
static constexpr GLColor32F kFloatGreen = {0.0f, 1.0f, 0.0f, 1.0f};
static constexpr GLColor32F kFloatBlue = {0.0f, 0.0f, 1.0f, 1.0f};
......
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