Commit a13f1061 by Le Hoang Quyen Committed by Commit Bot

Metal: Fix missing image view for texture from IOSurface.

Image view is used by glTexSubImage*, glCopySubImage* and glCopySubTexture*. This fixed some failed WebGL tests that make use of IOSurface. Bug: angleproject:4846 Bug: angleproject:2634 Change-Id: Iebcf840fdc1be2794feab766957b5848a361a63c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2356107 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 57393152
......@@ -767,6 +767,10 @@ angle::Result TextureMtl::bindTexImage(const gl::Context *context, egl::Surface
mLayeredTextureViews.resize(1);
mLayeredTextureViews[0] = mNativeTexture;
// Create image view for glTexSubImage* and glCopySubTexture*
ASSERT(mNativeTexture->mipmapLevels() == 1);
mTexImages[0][0] = mNativeTexture;
// Tell context to rebind textures
ContextMtl *contextMtl = mtl::GetImpl(context);
contextMtl->invalidateCurrentTextures();
......
......@@ -256,6 +256,11 @@ class IOSurfaceClientBufferTest : public ANGLETest
EGLSurface pbuffer;
bindIOSurfaceToTexture(ioSurface, 1, 1, 0, internalFormat, type, &pbuffer, &texture);
doSampleTestWithTexture(texture, mask);
}
void doSampleTestWithTexture(const GLTexture &texture, int mask)
{
constexpr char kVS[] =
"attribute vec4 position;\n"
"void main()\n"
......@@ -571,6 +576,35 @@ TEST_P(IOSurfaceClientBufferTest, BlitToIOSurface)
doBlitTest(false, 2, 2);
}
// Test using glCopyTexSubImage to copy to BGRX8888 IOSurfaces works.
TEST_P(IOSurfaceClientBufferTest, CopySubImageToBGRX8888IOSurface)
{
ANGLE_SKIP_TEST_IF(!hasIOSurfaceExt());
ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, 'BGRA', 4);
GLTexture texture;
glBindTexture(getGLTextureTarget(), texture);
glTexParameteri(getGLTextureTarget(), GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(getGLTextureTarget(), GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// Bind the IOSurface to a texture and clear it.
EGLSurface pbuffer;
bindIOSurfaceToTexture(ioSurface, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, &pbuffer, &texture);
// 1. Clear default framebuffer with desired color.
GLColor color(1, 2, 3, 4);
glClearColor(color.R / 255.f, color.G / 255.f, color.B / 255.f, color.A / 255.f);
glClear(GL_COLOR_BUFFER_BIT);
// 2. Copy color from default framebuffer to iosurface's bound texture.
glCopyTexSubImage2D(getGLTextureTarget(), 0, 0, 0, 0, 0, 1, 1);
EXPECT_GL_NO_ERROR();
// 3. Do texture sampling verification.
doSampleTestWithTexture(texture, R | G | B);
}
// Test the validation errors for missing attributes for eglCreatePbufferFromClientBuffer with
// IOSurface
TEST_P(IOSurfaceClientBufferTest, NegativeValidationMissingAttributes)
......
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