Commit 8c0bbfbb by Jeff Vigil Committed by Commit Bot

EGL: Implement EGL_ANDROID_framebuffer_target

Add attribute to configs. Add attribute matching logic. Does not set attribute in Vulkan configs, need solution to query Android for which formats are valid. anglebug.com/4208 New end2end test. Bug: angleproject:3961 Test: angle_end2end_tests --gtest_filter=EGLAndroidFramebufferTargetTest* Change-Id: I7e14c47b39e9539f6181c3c1d75c76fe63ca0f8c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1960508Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
parent 7dfc99e5
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"scripts/generate_loader.py": "scripts/generate_loader.py":
"48c60c668bec42a80378179aae2acc61", "48c60c668bec42a80378179aae2acc61",
"scripts/registry_xml.py": "scripts/registry_xml.py":
"78a90e53e3170645d2e24a9998cc7b16", "e817317edf2899585efcd8e521dcb23e",
"scripts/wgl.xml": "scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4", "aa96419c582af2f6673430e2847693f4",
"src/libEGL/egl_loader_autogen.cpp": "src/libEGL/egl_loader_autogen.cpp":
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"scripts/gl_angle_ext.xml": "scripts/gl_angle_ext.xml":
"d6907cd84d95ac0b32a164194eadcf53", "d6907cd84d95ac0b32a164194eadcf53",
"scripts/registry_xml.py": "scripts/registry_xml.py":
"78a90e53e3170645d2e24a9998cc7b16", "e817317edf2899585efcd8e521dcb23e",
"scripts/wgl.xml": "scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4", "aa96419c582af2f6673430e2847693f4",
"src/libANGLE/Context_gl_1_0_autogen.h": "src/libANGLE/Context_gl_1_0_autogen.h":
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"scripts/gl_angle_ext.xml": "scripts/gl_angle_ext.xml":
"d6907cd84d95ac0b32a164194eadcf53", "d6907cd84d95ac0b32a164194eadcf53",
"scripts/registry_xml.py": "scripts/registry_xml.py":
"78a90e53e3170645d2e24a9998cc7b16", "e817317edf2899585efcd8e521dcb23e",
"src/libANGLE/gl_enum_utils_autogen.cpp": "src/libANGLE/gl_enum_utils_autogen.cpp":
"fc023ad21e10d2279c8f14686bf838b6", "fc023ad21e10d2279c8f14686bf838b6",
"src/libANGLE/gl_enum_utils_autogen.h": "src/libANGLE/gl_enum_utils_autogen.h":
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"scripts/gl_angle_ext.xml": "scripts/gl_angle_ext.xml":
"d6907cd84d95ac0b32a164194eadcf53", "d6907cd84d95ac0b32a164194eadcf53",
"scripts/registry_xml.py": "scripts/registry_xml.py":
"78a90e53e3170645d2e24a9998cc7b16", "e817317edf2899585efcd8e521dcb23e",
"scripts/wgl.xml": "scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4", "aa96419c582af2f6673430e2847693f4",
"src/libGL/proc_table_wgl_autogen.cpp": "src/libGL/proc_table_wgl_autogen.cpp":
......
...@@ -106,6 +106,7 @@ supported_extensions = sorted(angle_extensions + gles1_extensions + gles_extensi ...@@ -106,6 +106,7 @@ supported_extensions = sorted(angle_extensions + gles1_extensions + gles_extensi
supported_egl_extensions = [ supported_egl_extensions = [
"EGL_ANDROID_blob_cache", "EGL_ANDROID_blob_cache",
"EGL_ANDROID_framebuffer_target",
"EGL_ANDROID_get_frame_timestamps", "EGL_ANDROID_get_frame_timestamps",
"EGL_ANDROID_get_native_client_buffer", "EGL_ANDROID_get_native_client_buffer",
"EGL_ANDROID_native_fence_sync", "EGL_ANDROID_native_fence_sync",
......
...@@ -1259,6 +1259,7 @@ std::vector<std::string> DisplayExtensions::getStrings() const ...@@ -1259,6 +1259,7 @@ std::vector<std::string> DisplayExtensions::getStrings() const
InsertExtensionString("EGL_ANGLE_create_context_extensions_enabled", createContextExtensionsEnabled, &extensionStrings); InsertExtensionString("EGL_ANGLE_create_context_extensions_enabled", createContextExtensionsEnabled, &extensionStrings);
InsertExtensionString("EGL_ANDROID_presentation_time", presentationTime, &extensionStrings); InsertExtensionString("EGL_ANDROID_presentation_time", presentationTime, &extensionStrings);
InsertExtensionString("EGL_ANDROID_blob_cache", blobCache, &extensionStrings); InsertExtensionString("EGL_ANDROID_blob_cache", blobCache, &extensionStrings);
InsertExtensionString("EGL_ANDROID_framebuffer_target", framebufferTargetANDROID, &extensionStrings);
InsertExtensionString("EGL_ANDROID_image_native_buffer", imageNativeBuffer, &extensionStrings); InsertExtensionString("EGL_ANDROID_image_native_buffer", imageNativeBuffer, &extensionStrings);
InsertExtensionString("EGL_ANDROID_get_frame_timestamps", getFrameTimestamps, &extensionStrings); InsertExtensionString("EGL_ANDROID_get_frame_timestamps", getFrameTimestamps, &extensionStrings);
InsertExtensionString("EGL_ANDROID_recordable", recordable, &extensionStrings); InsertExtensionString("EGL_ANDROID_recordable", recordable, &extensionStrings);
......
...@@ -990,6 +990,9 @@ struct DisplayExtensions ...@@ -990,6 +990,9 @@ struct DisplayExtensions
// EGL_EXT_gl_colorspace_display_p3_passthrough // EGL_EXT_gl_colorspace_display_p3_passthrough
bool glColorspaceDisplayP3Passthrough = false; bool glColorspaceDisplayP3Passthrough = false;
// EGL_ANDROID_framebuffer_target
bool framebufferTargetANDROID = false;
}; };
struct DeviceExtensions struct DeviceExtensions
......
...@@ -60,7 +60,8 @@ Config::Config() ...@@ -60,7 +60,8 @@ Config::Config()
transparentBlueValue(0), transparentBlueValue(0),
optimalOrientation(0), optimalOrientation(0),
colorComponentType(EGL_COLOR_COMPONENT_TYPE_FIXED_EXT), colorComponentType(EGL_COLOR_COMPONENT_TYPE_FIXED_EXT),
recordable(EGL_FALSE) recordable(EGL_FALSE),
framebufferTarget(EGL_FALSE) // TODO: http://anglebug.com/4208
{} {}
Config::~Config() {} Config::~Config() {}
...@@ -360,6 +361,9 @@ std::vector<const Config *> ConfigSet::filter(const AttributeMap &attributeMap) ...@@ -360,6 +361,9 @@ std::vector<const Config *> ConfigSet::filter(const AttributeMap &attributeMap)
case EGL_RECORDABLE_ANDROID: case EGL_RECORDABLE_ANDROID:
match = config.recordable == static_cast<EGLBoolean>(attributeValue); match = config.recordable == static_cast<EGLBoolean>(attributeValue);
break; break;
case EGL_FRAMEBUFFER_TARGET_ANDROID:
match = config.framebufferTarget == static_cast<EGLBoolean>(attributeValue);
break;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
......
...@@ -70,6 +70,9 @@ struct Config ...@@ -70,6 +70,9 @@ struct Config
EGLint optimalOrientation; // Optimal window surface orientation EGLint optimalOrientation; // Optimal window surface orientation
EGLenum colorComponentType; // Color component type EGLenum colorComponentType; // Color component type
EGLBoolean recordable; // EGL_TRUE if a surface can support recording on Android EGLBoolean recordable; // EGL_TRUE if a surface can support recording on Android
EGLBoolean framebufferTarget; // EGL_TRUE if the config supports rendering to a ANativeWindow
// for which the buffers are passed to the HWComposer HAL as a
// framebuffer target layer.
}; };
class ConfigSet class ConfigSet
......
...@@ -3712,6 +3712,9 @@ void QueryConfigAttrib(const Config *config, EGLint attribute, EGLint *value) ...@@ -3712,6 +3712,9 @@ void QueryConfigAttrib(const Config *config, EGLint attribute, EGLint *value)
case EGL_RECORDABLE_ANDROID: case EGL_RECORDABLE_ANDROID:
*value = config->recordable; *value = config->recordable;
break; break;
case EGL_FRAMEBUFFER_TARGET_ANDROID:
*value = config->framebufferTarget;
break;
default: default:
UNREACHABLE(); UNREACHABLE();
break; break;
......
...@@ -167,6 +167,8 @@ void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const ...@@ -167,6 +167,8 @@ void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
outExtensions->noConfigContext = mEGL->hasExtension("EGL_KHR_no_config_context"); outExtensions->noConfigContext = mEGL->hasExtension("EGL_KHR_no_config_context");
outExtensions->framebufferTargetANDROID = mEGL->hasExtension("EGL_ANDROID_framebuffer_target");
DisplayGL::generateExtensions(outExtensions); DisplayGL::generateExtensions(outExtensions);
} }
......
...@@ -194,6 +194,9 @@ void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const ...@@ -194,6 +194,9 @@ void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const
outExtensions->surfacelessContext = true; outExtensions->surfacelessContext = true;
outExtensions->glColorspace = getRenderer()->getFeatures().supportsSwapchainColorspace.enabled; outExtensions->glColorspace = getRenderer()->getFeatures().supportsSwapchainColorspace.enabled;
#if defined(ANGLE_PLATFORM_ANDROID)
outExtensions->framebufferTargetANDROID = true;
#endif // defined(ANGLE_PLATFORM_ANDROID)
outExtensions->noConfigContext = true; outExtensions->noConfigContext = true;
#if defined(ANGLE_PLATFORM_GGP) #if defined(ANGLE_PLATFORM_GGP)
......
...@@ -218,6 +218,13 @@ Error ValidateConfigAttribute(const Display *display, EGLAttrib attribute) ...@@ -218,6 +218,13 @@ Error ValidateConfigAttribute(const Display *display, EGLAttrib attribute)
} }
break; break;
case EGL_FRAMEBUFFER_TARGET_ANDROID:
if (!display->getExtensions().framebufferTargetANDROID)
{
return EglBadAttribute() << "EGL_ANDROID_framebuffer_target is not enabled.";
}
break;
default: default:
return EglBadAttribute() << "Unknown attribute."; return EglBadAttribute() << "Unknown attribute.";
} }
......
...@@ -135,6 +135,7 @@ angle_end2end_tests_sources = [ ...@@ -135,6 +135,7 @@ angle_end2end_tests_sources = [
"gl_tests/WebGLFramebufferTest.cpp", "gl_tests/WebGLFramebufferTest.cpp",
"gl_tests/WebGLReadOutsideFramebufferTest.cpp", "gl_tests/WebGLReadOutsideFramebufferTest.cpp",
"gl_tests/WEBGLVideoTextureTest.cpp", "gl_tests/WEBGLVideoTextureTest.cpp",
"egl_tests/EGLAndroidFrameBufferTargetTest.cpp",
"egl_tests/EGLBackwardsCompatibleContextTest.cpp", "egl_tests/EGLBackwardsCompatibleContextTest.cpp",
"egl_tests/EGLBlobCacheTest.cpp", "egl_tests/EGLBlobCacheTest.cpp",
"egl_tests/EGLChooseConfigTest.cpp", "egl_tests/EGLChooseConfigTest.cpp",
......
//
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// EGLAndroidFrameBufferTargetTest.cpp:
// This test verifies the extension EGL_ANDROID_framebuffer_target
// 1. When the EGLFRAME_BUFFER_TARGET_ANDROID attribute is used with eglChooseConfig
// It should match with configs according to Config selection rules and the extension
//
#include <gtest/gtest.h>
#include "common/string_utils.h"
#include "test_utils/ANGLETest.h"
using namespace angle;
class EGLAndroidFrameBufferTargetTest : public ANGLETest
{
protected:
EGLAndroidFrameBufferTargetTest() {}
void testSetUp() override
{
mDisplay = getEGLWindow()->getDisplay();
ASSERT_TRUE(mDisplay != EGL_NO_DISPLAY);
}
EGLDisplay mDisplay = EGL_NO_DISPLAY;
};
namespace
{
EGLint GetAttrib(EGLDisplay display, EGLConfig config, EGLint attrib)
{
EGLint value = 0;
EXPECT_EGL_TRUE(eglGetConfigAttrib(display, config, attrib, &value));
return value;
}
} // namespace
// Verify config matching is working.
TEST_P(EGLAndroidFrameBufferTargetTest, MatchFramebufferTargetConfigs)
{
ANGLE_SKIP_TEST_IF(!IsEGLDisplayExtensionEnabled(mDisplay, "EGL_ANDROID_framebuffer_target"));
// Get all the configs
EGLint count;
EXPECT_EGL_TRUE(eglGetConfigs(mDisplay, nullptr, 0, &count));
EXPECT_TRUE(count > 0);
std::vector<EGLConfig> configs(count);
EXPECT_EGL_TRUE(eglGetConfigs(mDisplay, configs.data(), count, &count));
ASSERT_EQ(configs.size(), static_cast<size_t>(count));
// Filter out all non-framebuffertarget configs
std::vector<EGLConfig> filterConfigs(0);
for (auto config : configs)
{
if (GetAttrib(mDisplay, config, EGL_FRAMEBUFFER_TARGET_ANDROID) == EGL_TRUE)
{
filterConfigs.push_back(config);
}
}
// sort configs by increaing ID
std::sort(filterConfigs.begin(), filterConfigs.end(), [this](EGLConfig a, EGLConfig b) -> bool {
return GetAttrib(mDisplay, a, EGL_CONFIG_ID) < GetAttrib(mDisplay, b, EGL_CONFIG_ID);
});
// Now get configs that selection algorithm identifies
EGLint attribs[] = {EGL_FRAMEBUFFER_TARGET_ANDROID,
EGL_TRUE,
EGL_COLOR_BUFFER_TYPE,
EGL_DONT_CARE,
EGL_COLOR_COMPONENT_TYPE_EXT,
EGL_DONT_CARE,
EGL_NONE};
EXPECT_EGL_TRUE(eglChooseConfig(mDisplay, attribs, nullptr, 0, &count));
std::vector<EGLConfig> matchConfigs(count);
EXPECT_EGL_TRUE(eglChooseConfig(mDisplay, attribs, matchConfigs.data(), count, &count));
matchConfigs.resize(count);
// sort configs by increasing ID
std::sort(matchConfigs.begin(), matchConfigs.end(), [this](EGLConfig a, EGLConfig b) -> bool {
return GetAttrib(mDisplay, a, EGL_CONFIG_ID) < GetAttrib(mDisplay, b, EGL_CONFIG_ID);
});
EXPECT_EQ(matchConfigs, filterConfigs) << "Filtered configs do not match selection Configs";
}
ANGLE_INSTANTIATE_TEST(EGLAndroidFrameBufferTargetTest, ES2_VULKAN(), ES3_VULKAN());
...@@ -28,6 +28,8 @@ class EGLPrintEGLinfoTest : public ANGLETest ...@@ -28,6 +28,8 @@ class EGLPrintEGLinfoTest : public ANGLETest
EGLDisplay mDisplay = EGL_NO_DISPLAY; EGLDisplay mDisplay = EGL_NO_DISPLAY;
}; };
namespace
{
// Parse space separated extension string into a vector of strings // Parse space separated extension string into a vector of strings
std::vector<std::string> ParseExtensions(const char *extensions) std::vector<std::string> ParseExtensions(const char *extensions)
{ {
...@@ -63,6 +65,8 @@ const char *GetGLString(EGLint name) ...@@ -63,6 +65,8 @@ const char *GetGLString(EGLint name)
return value; return value;
} }
} // namespace
// Print the EGL strings and extensions // Print the EGL strings and extensions
TEST_P(EGLPrintEGLinfoTest, PrintEGLInfo) TEST_P(EGLPrintEGLinfoTest, PrintEGLInfo)
{ {
...@@ -463,8 +467,16 @@ TEST_P(EGLPrintEGLinfoTest, PrintConfigInfo) ...@@ -463,8 +467,16 @@ TEST_P(EGLPrintEGLinfoTest, PrintConfigInfo)
std::cout << std::endl; std::cout << std::endl;
// Extensions // Extensions
std::cout << "\tAndroid Recordable: " << GetAttrib(mDisplay, config, EGL_RECORDABLE_ANDROID) if (IsEGLDisplayExtensionEnabled(mDisplay, "EGL_ANDROID_recordable"))
<< std::endl; {
std::cout << "\tAndroid Recordable: "
<< GetAttrib(mDisplay, config, EGL_RECORDABLE_ANDROID) << std::endl;
}
if (IsEGLDisplayExtensionEnabled(mDisplay, "EGL_ANDROID_framebuffer_target"))
{
std::cout << "\tAndroid framebuffer target: "
<< GetAttrib(mDisplay, config, EGL_FRAMEBUFFER_TARGET_ANDROID) << std::endl;
}
// Separator between configs // Separator between configs
std::cout << std::endl; std::cout << std::endl;
......
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