Skip to content

Commit

Permalink
EGL: Implement EGL_ANDROID_framebuffer_target
Browse files Browse the repository at this point in the history
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/+/1960508
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
  • Loading branch information
stonesthrow authored and Commit Bot committed Jan 7, 2020
1 parent 7dfc99e commit 8c0bbfb
Show file tree
Hide file tree
Showing 16 changed files with 137 additions and 7 deletions.
2 changes: 1 addition & 1 deletion scripts/code_generation_hashes/GL_EGL_WGL_loader.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts/generate_loader.py":
"48c60c668bec42a80378179aae2acc61",
"scripts/registry_xml.py":
"78a90e53e3170645d2e24a9998cc7b16",
"e817317edf2899585efcd8e521dcb23e",
"scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4",
"src/libEGL/egl_loader_autogen.cpp":
Expand Down
2 changes: 1 addition & 1 deletion scripts/code_generation_hashes/GL_EGL_entry_points.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"scripts/gl_angle_ext.xml":
"d6907cd84d95ac0b32a164194eadcf53",
"scripts/registry_xml.py":
"78a90e53e3170645d2e24a9998cc7b16",
"e817317edf2899585efcd8e521dcb23e",
"scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4",
"src/libANGLE/Context_gl_1_0_autogen.h":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts/gl_angle_ext.xml":
"d6907cd84d95ac0b32a164194eadcf53",
"scripts/registry_xml.py":
"78a90e53e3170645d2e24a9998cc7b16",
"e817317edf2899585efcd8e521dcb23e",
"src/libANGLE/gl_enum_utils_autogen.cpp":
"fc023ad21e10d2279c8f14686bf838b6",
"src/libANGLE/gl_enum_utils_autogen.h":
Expand Down
2 changes: 1 addition & 1 deletion scripts/code_generation_hashes/proc_table.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts/gl_angle_ext.xml":
"d6907cd84d95ac0b32a164194eadcf53",
"scripts/registry_xml.py":
"78a90e53e3170645d2e24a9998cc7b16",
"e817317edf2899585efcd8e521dcb23e",
"scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4",
"src/libGL/proc_table_wgl_autogen.cpp":
Expand Down
1 change: 1 addition & 0 deletions scripts/registry_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@

supported_egl_extensions = [
"EGL_ANDROID_blob_cache",
"EGL_ANDROID_framebuffer_target",
"EGL_ANDROID_get_frame_timestamps",
"EGL_ANDROID_get_native_client_buffer",
"EGL_ANDROID_native_fence_sync",
Expand Down
1 change: 1 addition & 0 deletions src/libANGLE/Caps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,7 @@ std::vector<std::string> DisplayExtensions::getStrings() const
InsertExtensionString("EGL_ANGLE_create_context_extensions_enabled", createContextExtensionsEnabled, &extensionStrings);
InsertExtensionString("EGL_ANDROID_presentation_time", presentationTime, &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_get_frame_timestamps", getFrameTimestamps, &extensionStrings);
InsertExtensionString("EGL_ANDROID_recordable", recordable, &extensionStrings);
Expand Down
3 changes: 3 additions & 0 deletions src/libANGLE/Caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,9 @@ struct DisplayExtensions

// EGL_EXT_gl_colorspace_display_p3_passthrough
bool glColorspaceDisplayP3Passthrough = false;

// EGL_ANDROID_framebuffer_target
bool framebufferTargetANDROID = false;
};

struct DeviceExtensions
Expand Down
6 changes: 5 additions & 1 deletion src/libANGLE/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ Config::Config()
transparentBlueValue(0),
optimalOrientation(0),
colorComponentType(EGL_COLOR_COMPONENT_TYPE_FIXED_EXT),
recordable(EGL_FALSE)
recordable(EGL_FALSE),
framebufferTarget(EGL_FALSE) // TODO: http://anglebug.com/4208
{}

Config::~Config() {}
Expand Down Expand Up @@ -360,6 +361,9 @@ std::vector<const Config *> ConfigSet::filter(const AttributeMap &attributeMap)
case EGL_RECORDABLE_ANDROID:
match = config.recordable == static_cast<EGLBoolean>(attributeValue);
break;
case EGL_FRAMEBUFFER_TARGET_ANDROID:
match = config.framebufferTarget == static_cast<EGLBoolean>(attributeValue);
break;
default:
UNREACHABLE();
}
Expand Down
3 changes: 3 additions & 0 deletions src/libANGLE/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ struct Config
EGLint optimalOrientation; // Optimal window surface orientation
EGLenum colorComponentType; // Color component type
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
Expand Down
3 changes: 3 additions & 0 deletions src/libANGLE/queryutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3712,6 +3712,9 @@ void QueryConfigAttrib(const Config *config, EGLint attribute, EGLint *value)
case EGL_RECORDABLE_ANDROID:
*value = config->recordable;
break;
case EGL_FRAMEBUFFER_TARGET_ANDROID:
*value = config->framebufferTarget;
break;
default:
UNREACHABLE();
break;
Expand Down
2 changes: 2 additions & 0 deletions src/libANGLE/renderer/gl/egl/DisplayEGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const

outExtensions->noConfigContext = mEGL->hasExtension("EGL_KHR_no_config_context");

outExtensions->framebufferTargetANDROID = mEGL->hasExtension("EGL_ANDROID_framebuffer_target");

DisplayGL::generateExtensions(outExtensions);
}

Expand Down
3 changes: 3 additions & 0 deletions src/libANGLE/renderer/vulkan/DisplayVk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const
outExtensions->surfacelessContext = true;
outExtensions->glColorspace = getRenderer()->getFeatures().supportsSwapchainColorspace.enabled;

#if defined(ANGLE_PLATFORM_ANDROID)
outExtensions->framebufferTargetANDROID = true;
#endif // defined(ANGLE_PLATFORM_ANDROID)
outExtensions->noConfigContext = true;

#if defined(ANGLE_PLATFORM_GGP)
Expand Down
7 changes: 7 additions & 0 deletions src/libANGLE/validationEGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ Error ValidateConfigAttribute(const Display *display, EGLAttrib attribute)
}
break;

case EGL_FRAMEBUFFER_TARGET_ANDROID:
if (!display->getExtensions().framebufferTargetANDROID)
{
return EglBadAttribute() << "EGL_ANDROID_framebuffer_target is not enabled.";
}
break;

default:
return EglBadAttribute() << "Unknown attribute.";
}
Expand Down
1 change: 1 addition & 0 deletions src/tests/angle_end2end_tests.gni
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ angle_end2end_tests_sources = [
"gl_tests/WebGLFramebufferTest.cpp",
"gl_tests/WebGLReadOutsideFramebufferTest.cpp",
"gl_tests/WEBGLVideoTextureTest.cpp",
"egl_tests/EGLAndroidFrameBufferTargetTest.cpp",
"egl_tests/EGLBackwardsCompatibleContextTest.cpp",
"egl_tests/EGLBlobCacheTest.cpp",
"egl_tests/EGLChooseConfigTest.cpp",
Expand Down
90 changes: 90 additions & 0 deletions src/tests/egl_tests/EGLAndroidFrameBufferTargetTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//
// 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());
16 changes: 14 additions & 2 deletions src/tests/egl_tests/EGLPrintEGLinfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class EGLPrintEGLinfoTest : public ANGLETest
EGLDisplay mDisplay = EGL_NO_DISPLAY;
};

namespace
{
// Parse space separated extension string into a vector of strings
std::vector<std::string> ParseExtensions(const char *extensions)
{
Expand Down Expand Up @@ -63,6 +65,8 @@ const char *GetGLString(EGLint name)
return value;
}

} // namespace

// Print the EGL strings and extensions
TEST_P(EGLPrintEGLinfoTest, PrintEGLInfo)
{
Expand Down Expand Up @@ -463,8 +467,16 @@ TEST_P(EGLPrintEGLinfoTest, PrintConfigInfo)
std::cout << std::endl;

// Extensions
std::cout << "\tAndroid Recordable: " << GetAttrib(mDisplay, config, EGL_RECORDABLE_ANDROID)
<< std::endl;
if (IsEGLDisplayExtensionEnabled(mDisplay, "EGL_ANDROID_recordable"))
{
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
std::cout << std::endl;
Expand Down

0 comments on commit 8c0bbfb

Please sign in to comment.