Commit ab95a449 by Geoff Lang Committed by Commit Bot

Textures that have bound surfaces are always renderable.

Chrome still tends to use ES2 contexts for most rasterization. This is a problem when trying to use FP16 IOSurfaces for rendering HDR because GL_RGBA16F is not renderable in ES2. Since a surface is always renderable, allow rendering to any textures with a bound surface. Update the tests to verify that ES3 formats can be used with ES2 contexts. Add tests for RGBA16F IOSurfaces. BUG: chromium:1103112 Change-Id: I9e8c082fc97a0e072289b097e71fc944988d4872 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2307454Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent ee9c4fe4
......@@ -1715,6 +1715,14 @@ bool Texture::isRenderable(const Context *context,
{
return ImageSibling::isRenderable(context, binding, imageIndex);
}
// Surfaces bound to textures are always renderable. This avoids issues with surfaces with ES3+
// formats not being renderable when bound to textures in ES2 contexts.
if (mBoundSurface)
{
return true;
}
return getAttachmentFormat(binding, imageIndex)
.info->textureAttachmentSupport(context->getClientVersion(), context->getExtensions());
}
......
......@@ -243,9 +243,13 @@ class IOSurfaceClientBufferTest : public ANGLETest
memcpy(IOSurfaceGetBaseAddress(ioSurface.get()), data, dataSize);
IOSurfaceUnlock(ioSurface.get(), 0, nullptr);
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;
GLTexture texture;
bindIOSurfaceToTexture(ioSurface, 1, 1, 0, internalFormat, type, &pbuffer, &texture);
constexpr char kVS[] =
......@@ -461,8 +465,6 @@ TEST_P(IOSurfaceClientBufferTest, RenderToR16IOSurface)
{
ANGLE_SKIP_TEST_IF(!hasIOSurfaceExt());
// This test only works on ES3.
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3);
// TODO(http://anglebug.com/4369)
ANGLE_SKIP_TEST_IF(isSwiftshader());
......@@ -481,8 +483,6 @@ TEST_P(IOSurfaceClientBufferTest, RenderToBGRA1010102IOSurface)
{
ANGLE_SKIP_TEST_IF(!hasIOSurfaceExt());
// This test only works on ES3.
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3);
// TODO(http://anglebug.com/4369)
ANGLE_SKIP_TEST_IF(isSwiftshader());
......@@ -497,9 +497,6 @@ TEST_P(IOSurfaceClientBufferTest, ReadFromBGRA1010102IOSurface)
{
ANGLE_SKIP_TEST_IF(!hasIOSurfaceExt());
// This test only works on ES3.
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3);
ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, 'l10r', 4);
uint32_t color = (3 << 30) | (1 << 22) | (2 << 12) | (3 << 2);
......@@ -507,6 +504,39 @@ TEST_P(IOSurfaceClientBufferTest, ReadFromBGRA1010102IOSurface)
R | G | B); // Don't test alpha, unorm '4' can't be represented with 2 bits.
}
// Test using RGBA_16F IOSurfaces for rendering
TEST_P(IOSurfaceClientBufferTest, RenderToRGBA16FIOSurface)
{
ANGLE_SKIP_TEST_IF(!hasIOSurfaceExt());
// TODO(http://anglebug.com/4369)
ANGLE_SKIP_TEST_IF(isSwiftshader());
ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, 'RGhA', 8);
std::array<GLushort, 4> color{
gl::float32ToFloat16(1.0f / 255.0f), gl::float32ToFloat16(2.0f / 255.0f),
gl::float32ToFloat16(3.0f / 255.0f), gl::float32ToFloat16(4.0f / 255.0f)};
doClearTest(ioSurface, GL_RGBA, GL_HALF_FLOAT, color);
}
// Test reading from RGBA_16F IOSurfaces
TEST_P(IOSurfaceClientBufferTest, ReadFromToRGBA16FIOSurfaceIOSurface)
{
ANGLE_SKIP_TEST_IF(!hasIOSurfaceExt());
// TODO(http://anglebug.com/4369)
ANGLE_SKIP_TEST_IF(isSwiftshader());
ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, 'RGhA', 8);
std::array<GLushort, 4> color{
gl::float32ToFloat16(1.0f / 255.0f), gl::float32ToFloat16(2.0f / 255.0f),
gl::float32ToFloat16(3.0f / 255.0f), gl::float32ToFloat16(4.0f / 255.0f)};
doSampleTest(ioSurface, GL_RGBA, GL_HALF_FLOAT, color.data(), sizeof(GLushort) * 4,
R | G | B | A);
}
// TODO(cwallez@chromium.org): Test using RGBA half float IOSurfaces ('RGhA')
// Test blitting from IOSurface
......
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