EGL: Add support for EGL_EXT_image_gl_colorspace extension

Add support for creating images with custom colorspace.

Bug: angleproject:3756
Tests: angle_end2end_tests --gtest_filter=ImageTest*
Change-Id: I9c332c012541c094728d9d9bde7add4189084a33
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2104088
Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
This commit is contained in:
Mohan Maiya 2020-04-08 18:26:46 -07:00 коммит произвёл Commit Bot
Родитель 728b917866
Коммит dac5cc3b6a
15 изменённых файлов: 363 добавлений и 72 удалений

Просмотреть файл

@ -164,6 +164,7 @@ Samsung Electronics, Inc.
Mohan Maiya
Peter Mowry
Sangwon Park
Saurabh Badenkal
Arm Ltd.
Fei Yang

Просмотреть файл

@ -10,7 +10,7 @@
"scripts/gl_angle_ext.xml":
"079cc4829de7ce638faf7bbf66e141ad",
"scripts/registry_xml.py":
"96820b40e5bb05b74d0bfbf5a19133fc",
"d48b9fcf30e2f98210f0b98824e7bd49",
"scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4",
"src/libEGL/egl_loader_autogen.cpp":

Просмотреть файл

@ -12,7 +12,7 @@
"scripts/gl_angle_ext.xml":
"079cc4829de7ce638faf7bbf66e141ad",
"scripts/registry_xml.py":
"96820b40e5bb05b74d0bfbf5a19133fc",
"d48b9fcf30e2f98210f0b98824e7bd49",
"scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4",
"src/libANGLE/Context_gl_1_0_autogen.h":

Просмотреть файл

@ -6,7 +6,7 @@
"scripts/gl_angle_ext.xml":
"079cc4829de7ce638faf7bbf66e141ad",
"scripts/registry_xml.py":
"96820b40e5bb05b74d0bfbf5a19133fc",
"d48b9fcf30e2f98210f0b98824e7bd49",
"src/libANGLE/gl_enum_utils_autogen.cpp":
"591432182a8cb304b7a3747ee6cc7b60",
"src/libANGLE/gl_enum_utils_autogen.h":

Просмотреть файл

@ -10,7 +10,7 @@
"scripts/gl_angle_ext.xml":
"079cc4829de7ce638faf7bbf66e141ad",
"scripts/registry_xml.py":
"96820b40e5bb05b74d0bfbf5a19133fc",
"d48b9fcf30e2f98210f0b98824e7bd49",
"scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4",
"src/libGL/proc_table_wgl_autogen.cpp":

Просмотреть файл

@ -133,6 +133,7 @@ supported_egl_extensions = [
"EGL_ANGLE_sync_control_rate",
"EGL_EXT_create_context_robustness",
"EGL_EXT_device_query",
"EGL_EXT_image_gl_colorspace",
"EGL_EXT_pixel_format_float",
"EGL_EXT_platform_base",
"EGL_EXT_platform_device",

Просмотреть файл

@ -1338,6 +1338,7 @@ std::vector<std::string> DisplayExtensions::getStrings() const
InsertExtensionString("EGL_KHR_image", image, &extensionStrings);
InsertExtensionString("EGL_KHR_image_base", imageBase, &extensionStrings);
InsertExtensionString("EGL_KHR_image_pixmap", imagePixmap, &extensionStrings);
InsertExtensionString("EGL_EXT_image_gl_colorspace", imageGlColorspace, &extensionStrings);
InsertExtensionString("EGL_KHR_gl_colorspace", glColorspace, &extensionStrings);
InsertExtensionString("EGL_EXT_gl_colorspace_scrgb", glColorspaceScrgb, &extensionStrings);
InsertExtensionString("EGL_EXT_gl_colorspace_scrgb_linear", glColorspaceScrgbLinear, &extensionStrings);

Просмотреть файл

@ -1048,6 +1048,9 @@ struct DisplayExtensions
// EGL_ANDROID_framebuffer_target
bool framebufferTargetANDROID = false;
// EGL_EXT_image_gl_colorspace
bool imageGlColorspace = false;
};
struct DeviceExtensions

Просмотреть файл

@ -225,7 +225,9 @@ ImageState::ImageState(EGLenum target, ImageSibling *buffer, const AttributeMap
format(GL_NONE),
size(),
samples(),
sourceType(target)
sourceType(target),
colorspace(
static_cast<EGLenum>(attribs.get(EGL_GL_COLORSPACE, EGL_GL_COLORSPACE_DEFAULT_EXT)))
{}
ImageState::~ImageState() {}
@ -392,7 +394,19 @@ Error Image::initialize(const Display *display)
ANGLE_TRY(rx::GetAs<ExternalImageSibling>(mState.source)->initialize(display));
}
mState.format = mState.source->getAttachmentFormat(GL_NONE, mState.imageIndex);
mState.format = mState.source->getAttachmentFormat(GL_NONE, mState.imageIndex);
if (mState.colorspace != EGL_GL_COLORSPACE_DEFAULT_EXT)
{
GLenum nonLinearFormat = mState.format.info->sizedInternalFormat;
if (!gl::ColorspaceFormatOverride(mState.colorspace, &nonLinearFormat))
{
// the colorspace format is not supported
return egl::EglBadMatch();
}
mState.format = gl::Format(nonLinearFormat);
}
mState.size = mState.source->getAttachmentSize(mState.imageIndex);
mState.samples = mState.source->getAttachmentSamples(mState.imageIndex);

Просмотреть файл

@ -135,6 +135,7 @@ struct ImageState : private angle::NonCopyable
gl::Extents size;
size_t samples;
EGLenum sourceType;
EGLenum colorspace;
};
class Image final : public RefCountObject, public LabeledObject

Просмотреть файл

@ -782,7 +782,7 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
AddRGBAFormat(&map, GL_RGB10_A2, true, 10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireES<3, 0>, AlwaysSupported, RequireES<3, 0>, RequireES<3, 0>, RequireES<3, 0>);
AddRGBAFormat(&map, GL_RGB10_A2UI, true, 10, 10, 10, 2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0>, NeverSupported);
AddRGBAFormat(&map, GL_SRGB8, true, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireES<3, 0>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
AddRGBAFormat(&map, GL_SRGB8_ALPHA8, true, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireES<3, 0>, AlwaysSupported, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::sRGB>, RequireESOrExt<3, 0, &Extensions::sRGB>);
AddRGBAFormat(&map, GL_SRGB8_ALPHA8, true, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESOrExt<3, 0, &Extensions::sRGB>, AlwaysSupported, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::sRGB>, RequireESOrExt<3, 0, &Extensions::sRGB>);
AddRGBAFormat(&map, GL_R11F_G11F_B10F, true, 11, 11, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT, false, RequireES<3, 0>, AlwaysSupported, RequireExt<&Extensions::colorBufferFloat>, RequireExt<&Extensions::colorBufferFloat>, RequireExt<&Extensions::colorBufferFloat>);
AddRGBAFormat(&map, GL_RGB9_E5, true, 9, 9, 9, 0, 5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT, false, RequireES<3, 0>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
AddRGBAFormat(&map, GL_R8I, true, 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0>, NeverSupported);

Просмотреть файл

@ -621,6 +621,7 @@ void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
mEGL->hasExtension("EGL_EXT_gl_colorspace_scrgb_linear");
outExtensions->glColorspaceDisplayP3Passthrough =
mEGL->hasExtension("EGL_EXT_gl_colorspace_display_p3_passthrough");
outExtensions->imageGlColorspace = mEGL->hasExtension("EGL_EXT_image_gl_colorspace");
}
outExtensions->imageNativeBuffer = mEGL->hasExtension("EGL_ANDROID_image_native_buffer");

Просмотреть файл

@ -211,6 +211,7 @@ void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const
getRenderer()->getFeatures().supportsAndroidHardwareBuffer.enabled;
outExtensions->surfacelessContext = true;
outExtensions->glColorspace = getRenderer()->getFeatures().supportsSwapchainColorspace.enabled;
outExtensions->imageGlColorspace = outExtensions->glColorspace;
#if defined(ANGLE_PLATFORM_ANDROID)
outExtensions->framebufferTargetANDROID = true;

Просмотреть файл

@ -2140,6 +2140,22 @@ Error ValidateCreateImage(const Display *display,
}
break;
case EGL_GL_COLORSPACE:
if (!displayExtensions.glColorspace)
{
return EglBadParameter() << "EGL_GL_COLORSPACE cannot be used "
"without EGL_KHR_gl_colorspace support.";
}
switch (value)
{
case EGL_GL_COLORSPACE_DEFAULT_EXT:
break;
default:
ANGLE_TRY(ValidateColorspaceAttribute(displayExtensions, value));
break;
}
break;
case EGL_TEXTURE_INTERNAL_FORMAT_ANGLE:
if (!displayExtensions.imageD3D11Texture)
{

Просмотреть файл

@ -15,15 +15,24 @@ namespace angle
{
namespace
{
constexpr char kOESExt[] = "GL_OES_EGL_image";
constexpr char kExternalExt[] = "GL_OES_EGL_image_external";
constexpr char kExternalESSL3Ext[] = "GL_OES_EGL_image_external_essl3";
constexpr char kBaseExt[] = "EGL_KHR_image_base";
constexpr char k2DTextureExt[] = "EGL_KHR_gl_texture_2D_image";
constexpr char k3DTextureExt[] = "EGL_KHR_gl_texture_3D_image";
constexpr char kPixmapExt[] = "EGL_KHR_image_pixmap";
constexpr char kRenderbufferExt[] = "EGL_KHR_gl_renderbuffer_image";
constexpr char kCubemapExt[] = "EGL_KHR_gl_texture_cubemap_image";
constexpr char kOESExt[] = "GL_OES_EGL_image";
constexpr char kExternalExt[] = "GL_OES_EGL_image_external";
constexpr char kExternalESSL3Ext[] = "GL_OES_EGL_image_external_essl3";
constexpr char kBaseExt[] = "EGL_KHR_image_base";
constexpr char k2DTextureExt[] = "EGL_KHR_gl_texture_2D_image";
constexpr char k3DTextureExt[] = "EGL_KHR_gl_texture_3D_image";
constexpr char kPixmapExt[] = "EGL_KHR_image_pixmap";
constexpr char kRenderbufferExt[] = "EGL_KHR_gl_renderbuffer_image";
constexpr char kCubemapExt[] = "EGL_KHR_gl_texture_cubemap_image";
constexpr char kImageGLColorspaceExt[] = "EGL_EXT_image_gl_colorspace";
constexpr EGLint kDefaultAttribs[] = {
EGL_IMAGE_PRESERVED,
EGL_TRUE,
EGL_NONE,
};
constexpr EGLint kColorspaceAttribs[] = {
EGL_IMAGE_PRESERVED, EGL_TRUE, EGL_GL_COLORSPACE, EGL_GL_COLORSPACE_SRGB_KHR, EGL_NONE,
};
} // anonymous namespace
class ImageTest : public ANGLETest
@ -137,6 +146,7 @@ class ImageTest : public ANGLETest
size_t height,
GLenum format,
GLenum type,
const EGLint *attribs,
void *data,
GLuint *outSourceTexture,
EGLImageKHR *outSourceImage)
@ -158,12 +168,6 @@ class ImageTest : public ANGLETest
// Create an image from the source texture
EGLWindow *window = getEGLWindow();
EGLint attribs[] = {
EGL_IMAGE_PRESERVED,
EGL_TRUE,
EGL_NONE,
};
EGLImageKHR image =
eglCreateImageKHR(window->getDisplay(), window->getContext(), EGL_GL_TEXTURE_2D_KHR,
reinterpretHelper<EGLClientBuffer>(source), attribs);
@ -178,6 +182,7 @@ class ImageTest : public ANGLETest
size_t height,
GLenum format,
GLenum type,
const EGLint *attribs,
uint8_t *data,
size_t dataStride,
EGLenum imageTarget,
@ -205,12 +210,6 @@ class ImageTest : public ANGLETest
// Create an image from the source texture
EGLWindow *window = getEGLWindow();
EGLint attribs[] = {
EGL_IMAGE_PRESERVED,
EGL_TRUE,
EGL_NONE,
};
EGLImageKHR image =
eglCreateImageKHR(window->getDisplay(), window->getContext(), imageTarget,
reinterpretHelper<EGLClientBuffer>(source), attribs);
@ -226,8 +225,8 @@ class ImageTest : public ANGLETest
size_t depth,
GLenum format,
GLenum type,
const EGLint *attribs,
void *data,
size_t imageLayer,
GLuint *outSourceTexture,
EGLImageKHR *outSourceImage)
{
@ -249,13 +248,6 @@ class ImageTest : public ANGLETest
// Create an image from the source texture
EGLWindow *window = getEGLWindow();
EGLint attribs[] = {
EGL_GL_TEXTURE_ZOFFSET_KHR,
static_cast<EGLint>(imageLayer),
EGL_IMAGE_PRESERVED,
EGL_TRUE,
EGL_NONE,
};
EGLImageKHR image =
eglCreateImageKHR(window->getDisplay(), window->getContext(), EGL_GL_TEXTURE_3D_KHR,
reinterpretHelper<EGLClientBuffer>(source), attribs);
@ -269,6 +261,7 @@ class ImageTest : public ANGLETest
void createEGLImageRenderbufferSource(size_t width,
size_t height,
GLenum internalFormat,
const EGLint *attribs,
GLubyte data[4],
GLuint *outSourceRenderbuffer,
EGLImageKHR *outSourceImage)
@ -296,12 +289,6 @@ class ImageTest : public ANGLETest
// Create an image from the source renderbuffer
EGLWindow *window = getEGLWindow();
EGLint attribs[] = {
EGL_IMAGE_PRESERVED,
EGL_TRUE,
EGL_NONE,
};
EGLImageKHR image =
eglCreateImageKHR(window->getDisplay(), window->getContext(), EGL_GL_RENDERBUFFER_KHR,
reinterpretHelper<EGLClientBuffer>(source), attribs);
@ -359,6 +346,24 @@ class ImageTest : public ANGLETest
*outTargetRenderbuffer = target;
}
void ValidationGLEGLImage_helper(const EGLint *attribs);
void Source2DTarget2D_helper(const EGLint *attribs);
void Source2DTargetRenderbuffer_helper(const EGLint *attribs);
void Source2DTargetExternal_helper(const EGLint *attribs);
void Source2DTargetExternalESSL3_helper(const EGLint *attribs);
void SourceCubeTarget2D_helper(const EGLint *attribs);
void SourceCubeTargetRenderbuffer_helper(const EGLint *attribs);
void SourceCubeTargetExternal_helper(const EGLint *attribs);
void SourceCubeTargetExternalESSL3_helper(const EGLint *attribs);
void Source3DTargetTexture_helper(const bool withColorspace);
void Source3DTargetRenderbuffer_helper(const bool withColorspace);
void Source3DTargetExternal_helper(const bool withColorspace);
void Source3DTargetExternalESSL3_helper(const bool withColorspace);
void SourceRenderbufferTargetTexture_helper(const EGLint *attribs);
void SourceRenderbufferTargetTextureExternal_helper(const EGLint *attribs);
void SourceRenderbufferTargetRenderbuffer_helper(const EGLint *attribs);
void SourceRenderbufferTargetTextureExternalESSL3_helper(const EGLint *attribs);
void verifyResultsTexture(GLuint texture,
GLubyte data[4],
GLenum textureTarget,
@ -418,6 +423,11 @@ class ImageTest : public ANGLETest
return reinterpret_cast<destType>(sourceSizeT);
}
bool hasImageGLColorspaceExt() const
{
return IsEGLDisplayExtensionEnabled(getEGLWindow()->getDisplay(), kImageGLColorspaceExt);
}
bool hasOESExt() const { return IsGLExtensionEnabled(kOESExt); }
bool hasExternalExt() const { return IsGLExtensionEnabled(kExternalExt); }
@ -454,6 +464,30 @@ class ImageTest : public ANGLETest
return IsEGLDisplayExtensionEnabled(getEGLWindow()->getDisplay(), kCubemapExt);
}
EGLint *get3DAttributes(const bool withColorspace = false, EGLint layer = 0)
{
if (!withColorspace)
{
default3DAttribs[1] = static_cast<EGLint>(layer);
return default3DAttribs;
}
colorspace3DAttribs[1] = static_cast<EGLint>(layer);
return colorspace3DAttribs;
}
EGLint default3DAttribs[5] = {
EGL_GL_TEXTURE_ZOFFSET_KHR, static_cast<EGLint>(0), EGL_IMAGE_PRESERVED, EGL_TRUE, EGL_NONE,
};
EGLint colorspace3DAttribs[7] = {
EGL_GL_TEXTURE_ZOFFSET_KHR,
static_cast<EGLint>(0),
EGL_IMAGE_PRESERVED,
EGL_TRUE,
EGL_GL_COLORSPACE,
EGL_GL_COLORSPACE_SRGB_KHR,
EGL_NONE,
};
GLuint mTextureProgram;
GLint mTextureUniformLocation;
@ -921,6 +955,18 @@ TEST_P(ImageTest, ValidationGLImage)
// Check validation from the GL_OES_EGL_image extension
TEST_P(ImageTest, ValidationGLEGLImage)
{
ValidationGLEGLImage_helper(kDefaultAttribs);
}
TEST_P(ImageTest, ValidationGLEGLImage_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_sRGB"));
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
ValidationGLEGLImage_helper(kColorspaceAttribs);
}
void ImageTest::ValidationGLEGLImage_helper(const EGLint *attribs)
{
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !has2DTextureExt());
@ -929,7 +975,7 @@ TEST_P(ImageTest, ValidationGLEGLImage)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, data, &source, &image);
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, attribs, data, &source, &image);
// If <target> is not TEXTURE_2D, the error INVALID_ENUM is generated.
glEGLImageTargetTexture2DOES(GL_TEXTURE_CUBE_MAP_POSITIVE_X, image);
@ -1087,6 +1133,18 @@ TEST_P(ImageTest, ValidationGLEGLImageExternalESSL3)
}
TEST_P(ImageTest, Source2DTarget2D)
{
Source2DTarget2D_helper(kDefaultAttribs);
}
TEST_P(ImageTest, Source2DTarget2D_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_sRGB"));
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
Source2DTarget2D_helper(kColorspaceAttribs);
}
void ImageTest::Source2DTarget2D_helper(const EGLint *attribs)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !has2DTextureExt());
@ -1096,7 +1154,7 @@ TEST_P(ImageTest, Source2DTarget2D)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, data, &source, &image);
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, attribs, data, &source, &image);
// Create the target
GLuint target;
@ -1113,6 +1171,19 @@ TEST_P(ImageTest, Source2DTarget2D)
TEST_P(ImageTest, Source2DTargetRenderbuffer)
{
Source2DTargetRenderbuffer_helper(kDefaultAttribs);
}
TEST_P(ImageTest, Source2DTargetRenderbuffer_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3);
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
Source2DTargetRenderbuffer_helper(kColorspaceAttribs);
}
void ImageTest::Source2DTargetRenderbuffer_helper(const EGLint *attribs)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !has2DTextureExt());
@ -1121,7 +1192,7 @@ TEST_P(ImageTest, Source2DTargetRenderbuffer)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, data, &source, &image);
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, attribs, data, &source, &image);
// Create the target
GLuint target;
@ -1137,6 +1208,18 @@ TEST_P(ImageTest, Source2DTargetRenderbuffer)
}
TEST_P(ImageTest, Source2DTargetExternal)
{
Source2DTargetExternal_helper(kDefaultAttribs);
}
TEST_P(ImageTest, Source2DTargetExternal_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_sRGB"));
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
Source2DTargetExternal_helper(kColorspaceAttribs);
}
void ImageTest::Source2DTargetExternal_helper(const EGLint *attribs)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !has2DTextureExt() || !hasExternalExt());
@ -1149,7 +1232,7 @@ TEST_P(ImageTest, Source2DTargetExternal)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, data, &source, &image);
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, attribs, data, &source, &image);
// Create the target
GLuint target;
@ -1165,6 +1248,18 @@ TEST_P(ImageTest, Source2DTargetExternal)
}
TEST_P(ImageTestES3, Source2DTargetExternalESSL3)
{
Source2DTargetExternalESSL3_helper(kDefaultAttribs);
}
TEST_P(ImageTestES3, Source2DTargetExternalESSL3_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_sRGB"));
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
Source2DTargetExternalESSL3_helper(kColorspaceAttribs);
}
void ImageTest::Source2DTargetExternalESSL3_helper(const EGLint *attribs)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !has2DTextureExt() ||
@ -1175,7 +1270,7 @@ TEST_P(ImageTestES3, Source2DTargetExternalESSL3)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, data, &source, &image);
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, attribs, data, &source, &image);
// Create the target
GLuint target;
@ -1191,6 +1286,18 @@ TEST_P(ImageTestES3, Source2DTargetExternalESSL3)
}
TEST_P(ImageTest, SourceCubeTarget2D)
{
SourceCubeTarget2D_helper(kDefaultAttribs);
}
TEST_P(ImageTest, SourceCubeTarget2D_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_sRGB"));
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
SourceCubeTarget2D_helper(kColorspaceAttribs);
}
void ImageTest::SourceCubeTarget2D_helper(const EGLint *attribs)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !hasCubemapExt());
@ -1206,8 +1313,8 @@ TEST_P(ImageTest, SourceCubeTarget2D)
GLuint source;
EGLImageKHR image;
createEGLImageCubemapTextureSource(
1, 1, GL_RGBA, GL_UNSIGNED_BYTE, reinterpret_cast<uint8_t *>(data), sizeof(GLubyte) * 4,
EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR + faceIdx, &source, &image);
1, 1, GL_RGBA, GL_UNSIGNED_BYTE, attribs, reinterpret_cast<uint8_t *>(data),
sizeof(GLubyte) * 4, EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR + faceIdx, &source, &image);
// Create the target
GLuint target;
@ -1224,6 +1331,18 @@ TEST_P(ImageTest, SourceCubeTarget2D)
}
TEST_P(ImageTest, SourceCubeTargetRenderbuffer)
{
SourceCubeTargetRenderbuffer_helper(kDefaultAttribs);
}
TEST_P(ImageTest, SourceCubeTargetRenderbuffer_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3);
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
SourceCubeTargetRenderbuffer_helper(kColorspaceAttribs);
}
void ImageTest::SourceCubeTargetRenderbuffer_helper(const EGLint *attribs)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !hasCubemapExt());
@ -1242,8 +1361,8 @@ TEST_P(ImageTest, SourceCubeTargetRenderbuffer)
GLuint source;
EGLImageKHR image;
createEGLImageCubemapTextureSource(
1, 1, GL_RGBA, GL_UNSIGNED_BYTE, reinterpret_cast<uint8_t *>(data), sizeof(GLubyte) * 4,
EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR + faceIdx, &source, &image);
1, 1, GL_RGBA, GL_UNSIGNED_BYTE, attribs, reinterpret_cast<uint8_t *>(data),
sizeof(GLubyte) * 4, EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR + faceIdx, &source, &image);
// Create the target
GLuint target;
@ -1261,6 +1380,18 @@ TEST_P(ImageTest, SourceCubeTargetRenderbuffer)
// Test cubemap -> external texture EGL images.
TEST_P(ImageTest, SourceCubeTargetExternal)
{
SourceCubeTargetExternal_helper(kDefaultAttribs);
}
TEST_P(ImageTest, SourceCubeTargetExternal_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_sRGB"));
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
SourceCubeTargetExternal_helper(kColorspaceAttribs);
}
void ImageTest::SourceCubeTargetExternal_helper(const EGLint *attribs)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !hasCubemapExt() || !hasExternalExt());
@ -1279,8 +1410,8 @@ TEST_P(ImageTest, SourceCubeTargetExternal)
GLuint source;
EGLImageKHR image;
createEGLImageCubemapTextureSource(
1, 1, GL_RGBA, GL_UNSIGNED_BYTE, reinterpret_cast<uint8_t *>(data), sizeof(GLubyte) * 4,
EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR + faceIdx, &source, &image);
1, 1, GL_RGBA, GL_UNSIGNED_BYTE, attribs, reinterpret_cast<uint8_t *>(data),
sizeof(GLubyte) * 4, EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR + faceIdx, &source, &image);
// Create the target
GLuint target;
@ -1298,6 +1429,18 @@ TEST_P(ImageTest, SourceCubeTargetExternal)
// Test cubemap -> external texture EGL images using ESSL3 shaders.
TEST_P(ImageTestES3, SourceCubeTargetExternalESSL3)
{
SourceCubeTargetExternalESSL3_helper(kDefaultAttribs);
}
TEST_P(ImageTestES3, SourceCubeTargetExternalESSL3_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_sRGB"));
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
SourceCubeTargetExternalESSL3_helper(kColorspaceAttribs);
}
void ImageTest::SourceCubeTargetExternalESSL3_helper(const EGLint *attribs)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasExternalESSL3Ext() || !hasBaseExt() || !hasCubemapExt());
@ -1313,8 +1456,8 @@ TEST_P(ImageTestES3, SourceCubeTargetExternalESSL3)
GLuint source;
EGLImageKHR image;
createEGLImageCubemapTextureSource(
1, 1, GL_RGBA, GL_UNSIGNED_BYTE, reinterpret_cast<uint8_t *>(data), sizeof(GLubyte) * 4,
EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR + faceIdx, &source, &image);
1, 1, GL_RGBA, GL_UNSIGNED_BYTE, attribs, reinterpret_cast<uint8_t *>(data),
sizeof(GLubyte) * 4, EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR + faceIdx, &source, &image);
// Create the target
GLuint target;
@ -1331,6 +1474,18 @@ TEST_P(ImageTestES3, SourceCubeTargetExternalESSL3)
}
TEST_P(ImageTest, Source3DTargetTexture)
{
Source3DTargetTexture_helper(false);
}
TEST_P(ImageTest, Source3DTargetTexture_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_sRGB"));
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
Source3DTargetTexture_helper(true);
}
void ImageTest::Source3DTargetTexture_helper(const bool withColorspace)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !has3DTextureExt());
@ -1347,7 +1502,8 @@ TEST_P(ImageTest, Source3DTargetTexture)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage3DTextureSource(1, 1, depth, GL_RGBA, GL_UNSIGNED_BYTE, data, layer, &source,
createEGLImage3DTextureSource(1, 1, depth, GL_RGBA, GL_UNSIGNED_BYTE,
get3DAttributes(withColorspace, layer), data, &source,
&image);
// Create the target
@ -1366,8 +1522,21 @@ TEST_P(ImageTest, Source3DTargetTexture)
TEST_P(ImageTest, Source3DTargetRenderbuffer)
{
// Qualcom drivers appear to always bind the 0 layer of the source 3D texture when the target is
// a renderbuffer. They work correctly when the target is a 2D texture. http://anglebug.com/2745
Source3DTargetRenderbuffer_helper(false);
}
TEST_P(ImageTest, Source3DTargetRenderbuffer_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3);
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
Source3DTargetRenderbuffer_helper(true);
}
void ImageTest::Source3DTargetRenderbuffer_helper(const bool withColorspace)
{
// Qualcom drivers appear to always bind the 0 layer of the source 3D texture when the
// target is a renderbuffer. They work correctly when the target is a 2D texture.
// http://anglebug.com/2745
ANGLE_SKIP_TEST_IF(IsAndroid() && IsOpenGLES());
EGLWindow *window = getEGLWindow();
@ -1385,7 +1554,9 @@ TEST_P(ImageTest, Source3DTargetRenderbuffer)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage3DTextureSource(1, 1, depth, GL_RGBA, GL_UNSIGNED_BYTE, data, layer, &source,
createEGLImage3DTextureSource(1, 1, depth, GL_RGBA, GL_UNSIGNED_BYTE,
get3DAttributes(withColorspace, layer), data, &source,
&image);
// Create the target
@ -1404,6 +1575,18 @@ TEST_P(ImageTest, Source3DTargetRenderbuffer)
// Test 3D -> external texture EGL images.
TEST_P(ImageTest, Source3DTargetExternal)
{
Source3DTargetExternal_helper(false);
}
TEST_P(ImageTest, Source3DTargetExternal_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_sRGB"));
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
Source3DTargetExternal_helper(true);
}
void ImageTest::Source3DTargetExternal_helper(const bool withColorspace)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasExternalExt() || !hasBaseExt() || !has3DTextureExt());
@ -1423,7 +1606,8 @@ TEST_P(ImageTest, Source3DTargetExternal)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage3DTextureSource(1, 1, depth, GL_RGBA, GL_UNSIGNED_BYTE, data, layer, &source,
createEGLImage3DTextureSource(1, 1, depth, GL_RGBA, GL_UNSIGNED_BYTE,
get3DAttributes(withColorspace, layer), data, &source,
&image);
// Create the target
@ -1442,6 +1626,18 @@ TEST_P(ImageTest, Source3DTargetExternal)
// Test 3D -> external texture EGL images using ESSL3 shaders.
TEST_P(ImageTestES3, Source3DTargetExternalESSL3)
{
Source3DTargetExternalESSL3_helper(false);
}
TEST_P(ImageTestES3, Source3DTargetExternalESSL3_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_sRGB"));
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
Source3DTargetExternalESSL3_helper(true);
}
void ImageTest::Source3DTargetExternalESSL3_helper(const bool withColorspace)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasExternalESSL3Ext() || !hasBaseExt() ||
@ -1459,7 +1655,9 @@ TEST_P(ImageTestES3, Source3DTargetExternalESSL3)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage3DTextureSource(1, 1, depth, GL_RGBA, GL_UNSIGNED_BYTE, data, layer, &source,
createEGLImage3DTextureSource(1, 1, depth, GL_RGBA, GL_UNSIGNED_BYTE,
get3DAttributes(withColorspace, layer), data, &source,
&image);
// Create the target
@ -1477,6 +1675,18 @@ TEST_P(ImageTestES3, Source3DTargetExternalESSL3)
}
TEST_P(ImageTest, SourceRenderbufferTargetTexture)
{
SourceRenderbufferTargetTexture_helper(kDefaultAttribs);
}
TEST_P(ImageTest, SourceRenderbufferTargetTexture_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_sRGB"));
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
SourceRenderbufferTargetTexture_helper(kColorspaceAttribs);
}
void ImageTest::SourceRenderbufferTargetTexture_helper(const EGLint *attribs)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !hasRenderbufferExt());
@ -1486,7 +1696,7 @@ TEST_P(ImageTest, SourceRenderbufferTargetTexture)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImageRenderbufferSource(1, 1, GL_RGBA8_OES, data, &source, &image);
createEGLImageRenderbufferSource(1, 1, GL_RGBA8_OES, attribs, data, &source, &image);
// Create the target
GLuint target;
@ -1503,6 +1713,18 @@ TEST_P(ImageTest, SourceRenderbufferTargetTexture)
// Test renderbuffer -> external texture EGL images.
TEST_P(ImageTest, SourceRenderbufferTargetTextureExternal)
{
SourceRenderbufferTargetTextureExternal_helper(kDefaultAttribs);
}
TEST_P(ImageTest, SourceRenderbufferTargetTextureExternal_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_sRGB"));
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
SourceRenderbufferTargetTextureExternal_helper(kColorspaceAttribs);
}
void ImageTest::SourceRenderbufferTargetTextureExternal_helper(const EGLint *attribs)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasExternalExt() || !hasBaseExt() || !hasRenderbufferExt());
@ -1515,7 +1737,7 @@ TEST_P(ImageTest, SourceRenderbufferTargetTextureExternal)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImageRenderbufferSource(1, 1, GL_RGBA8_OES, data, &source, &image);
createEGLImageRenderbufferSource(1, 1, GL_RGBA8_OES, attribs, data, &source, &image);
// Create the target
GLuint target;
@ -1532,6 +1754,18 @@ TEST_P(ImageTest, SourceRenderbufferTargetTextureExternal)
// Test renderbuffer -> external texture EGL images using ESSL3 shaders.
TEST_P(ImageTestES3, SourceRenderbufferTargetTextureExternalESSL3)
{
SourceRenderbufferTargetTextureExternalESSL3_helper(kDefaultAttribs);
}
TEST_P(ImageTestES3, SourceRenderbufferTargetTextureExternalESSL3_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_sRGB"));
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
SourceRenderbufferTargetTextureExternalESSL3_helper(kColorspaceAttribs);
}
void ImageTest::SourceRenderbufferTargetTextureExternalESSL3_helper(const EGLint *attribs)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasExternalESSL3Ext() || !hasBaseExt() ||
@ -1542,7 +1776,7 @@ TEST_P(ImageTestES3, SourceRenderbufferTargetTextureExternalESSL3)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImageRenderbufferSource(1, 1, GL_RGBA8_OES, data, &source, &image);
createEGLImageRenderbufferSource(1, 1, GL_RGBA8_OES, attribs, data, &source, &image);
// Create the target
GLuint target;
@ -1558,6 +1792,18 @@ TEST_P(ImageTestES3, SourceRenderbufferTargetTextureExternalESSL3)
}
TEST_P(ImageTest, SourceRenderbufferTargetRenderbuffer)
{
SourceRenderbufferTargetRenderbuffer_helper(kDefaultAttribs);
}
TEST_P(ImageTest, SourceRenderbufferTargetRenderbuffer_Colorspace)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_sRGB"));
ANGLE_SKIP_TEST_IF(!hasImageGLColorspaceExt());
SourceRenderbufferTargetRenderbuffer_helper(kColorspaceAttribs);
}
void ImageTest::SourceRenderbufferTargetRenderbuffer_helper(const EGLint *attribs)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !hasRenderbufferExt());
@ -1567,7 +1813,7 @@ TEST_P(ImageTest, SourceRenderbufferTargetRenderbuffer)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImageRenderbufferSource(1, 1, GL_RGBA8_OES, data, &source, &image);
createEGLImageRenderbufferSource(1, 1, GL_RGBA8_OES, attribs, data, &source, &image);
// Create the target
GLuint target;
@ -1596,7 +1842,8 @@ TEST_P(ImageTest, Deletion)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, originalData, &source, &image);
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, kDefaultAttribs, originalData,
&source, &image);
// Create multiple targets
GLuint targetTexture;
@ -1762,7 +2009,8 @@ TEST_P(ImageTest, Respecification)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, originalData, &source, &image);
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, kDefaultAttribs, originalData,
&source, &image);
// Create the target
GLuint target;
@ -1797,7 +2045,8 @@ TEST_P(ImageTest, RespecificationDifferentSize)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, originalData, &source, &image);
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, kDefaultAttribs, originalData,
&source, &image);
// Create the target
GLuint target;
@ -1835,7 +2084,8 @@ TEST_P(ImageTest, RespecificationWithFBO)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, originalData, &source, &image);
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, kDefaultAttribs, originalData,
&source, &image);
// Create the target
GLuint target;
@ -1894,7 +2144,8 @@ TEST_P(ImageTest, RespecificationOfOtherLevel)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage2DTextureSource(2, 2, GL_RGBA, GL_UNSIGNED_BYTE, originalData, &source, &image);
createEGLImage2DTextureSource(2, 2, GL_RGBA, GL_UNSIGNED_BYTE, kDefaultAttribs, originalData,
&source, &image);
// Create the target
GLuint target;
@ -1939,7 +2190,8 @@ TEST_P(ImageTest, UpdatedData)
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, originalData, &source, &image);
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, kDefaultAttribs, originalData,
&source, &image);
// Create multiple targets
GLuint targetTexture;
@ -1982,4 +2234,4 @@ TEST_P(ImageTest, UpdatedData)
// tests should be run against.
ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(ImageTest);
ANGLE_INSTANTIATE_TEST_ES3(ImageTestES3);
} // namespace angle
} // namespace angle