Commit 942d9152 by Mohan Maiya Committed by Commit Bot

EGL: Add support for EGL_KHR_gl_colorspace extension

If the Vulkan backend supports VK_EXT_swapchain_colorspace extension, enable the option for applications to create surfaces with non-linear formats. Not all formats have non-linear versions and is platform specific. Tests: dEQP-EGL.functional.wide_color.* angle_deqp_egl_tests --use-angle=vulkan --deqp-gl-context-type=egl --deqp-case=dEQP-EGL.functional.wide_color.* Bug: angleproject:2514 Change-Id: I441ee797cceef92c84473bfa18605c4fd8180de1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1951963 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent c1fc6de8
...@@ -28,17 +28,17 @@ extern "C" { ...@@ -28,17 +28,17 @@ extern "C" {
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/ */
/* /*
** This header is generated from the Khronos OpenGL / OpenGL ES XML ** This header is generated from the Khronos EGL XML API Registry.
** API Registry. The current version of the Registry, generator scripts ** The current version of the Registry, generator scripts
** used to make the header, and the header can be found at ** used to make the header, and the header can be found at
** http://www.khronos.org/registry/egl ** http://www.khronos.org/registry/egl
** **
** Khronos $Git commit SHA1: bae3518c48 $ on $Git commit date: 2018-05-17 10:56:57 -0700 $ ** Khronos $Git commit SHA1: cb927ca98d $ on $Git commit date: 2019-08-08 01:05:38 -0700 $
*/ */
#include <EGL/eglplatform.h> #include <EGL/eglplatform.h>
#define EGL_EGLEXT_VERSION 20180517 #define EGL_EGLEXT_VERSION 20190808
/* Generated C header for: /* Generated C header for:
* API: egl * API: egl
...@@ -462,6 +462,10 @@ EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLin ...@@ -462,6 +462,10 @@ EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLin
#endif #endif
#endif /* EGL_KHR_wait_sync */ #endif /* EGL_KHR_wait_sync */
#ifndef EGL_ANDROID_GLES_layers
#define EGL_ANDROID_GLES_layers 1
#endif /* EGL_ANDROID_GLES_layers */
#ifndef EGL_ANDROID_blob_cache #ifndef EGL_ANDROID_blob_cache
#define EGL_ANDROID_blob_cache 1 #define EGL_ANDROID_blob_cache 1
typedef khronos_ssize_t EGLsizeiANDROID; typedef khronos_ssize_t EGLsizeiANDROID;
...@@ -681,6 +685,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint a ...@@ -681,6 +685,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint a
#ifndef EGL_EXT_device_drm #ifndef EGL_EXT_device_drm
#define EGL_EXT_device_drm 1 #define EGL_EXT_device_drm 1
#define EGL_DRM_DEVICE_FILE_EXT 0x3233 #define EGL_DRM_DEVICE_FILE_EXT 0x3233
#define EGL_DRM_MASTER_FD_EXT 0x333C
#endif /* EGL_EXT_device_drm */ #endif /* EGL_EXT_device_drm */
#ifndef EGL_EXT_device_enumeration #ifndef EGL_EXT_device_enumeration
...@@ -716,6 +721,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint a ...@@ -716,6 +721,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint a
#define EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT 0x3362 #define EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT 0x3362
#endif /* EGL_EXT_gl_colorspace_display_p3_linear */ #endif /* EGL_EXT_gl_colorspace_display_p3_linear */
#ifndef EGL_EXT_gl_colorspace_display_p3_passthrough
#define EGL_EXT_gl_colorspace_display_p3_passthrough 1
#define EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT 0x3490
#endif /* EGL_EXT_gl_colorspace_display_p3_passthrough */
#ifndef EGL_EXT_gl_colorspace_scrgb #ifndef EGL_EXT_gl_colorspace_scrgb
#define EGL_EXT_gl_colorspace_scrgb 1 #define EGL_EXT_gl_colorspace_scrgb 1
#define EGL_GL_COLORSPACE_SCRGB_EXT 0x3351 #define EGL_GL_COLORSPACE_SCRGB_EXT 0x3351
...@@ -1025,6 +1035,16 @@ EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageMESA (EGLDisplay dpy, EGLImage ...@@ -1025,6 +1035,16 @@ EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageMESA (EGLDisplay dpy, EGLImage
#define EGL_PLATFORM_SURFACELESS_MESA 0x31DD #define EGL_PLATFORM_SURFACELESS_MESA 0x31DD
#endif /* EGL_MESA_platform_surfaceless */ #endif /* EGL_MESA_platform_surfaceless */
#ifndef EGL_MESA_query_driver
#define EGL_MESA_query_driver 1
typedef char *(EGLAPIENTRYP PFNEGLGETDISPLAYDRIVERCONFIGPROC) (EGLDisplay dpy);
typedef const char *(EGLAPIENTRYP PFNEGLGETDISPLAYDRIVERNAMEPROC) (EGLDisplay dpy);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI char *EGLAPIENTRY eglGetDisplayDriverConfig (EGLDisplay dpy);
EGLAPI const char *EGLAPIENTRY eglGetDisplayDriverName (EGLDisplay dpy);
#endif
#endif /* EGL_MESA_query_driver */
#ifndef EGL_NOK_swap_region #ifndef EGL_NOK_swap_region
#define EGL_NOK_swap_region 1 #define EGL_NOK_swap_region 1
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects);
...@@ -1113,6 +1133,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface sur ...@@ -1113,6 +1133,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface sur
#endif #endif
#endif /* EGL_NV_post_sub_buffer */ #endif /* EGL_NV_post_sub_buffer */
#ifndef EGL_NV_quadruple_buffer
#define EGL_NV_quadruple_buffer 1
#define EGL_QUADRUPLE_BUFFER_NV 0x3231
#endif /* EGL_NV_quadruple_buffer */
#ifndef EGL_NV_robustness_video_memory_purge #ifndef EGL_NV_robustness_video_memory_purge
#define EGL_NV_robustness_video_memory_purge 1 #define EGL_NV_robustness_video_memory_purge 1
#define EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x334C #define EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x334C
...@@ -1154,6 +1179,12 @@ EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalAttribsNV (EGLDi ...@@ -1154,6 +1179,12 @@ EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalAttribsNV (EGLDi
#define EGL_STREAM_CROSS_SYSTEM_NV 0x334F #define EGL_STREAM_CROSS_SYSTEM_NV 0x334F
#endif /* EGL_NV_stream_cross_system */ #endif /* EGL_NV_stream_cross_system */
#ifndef EGL_NV_stream_dma
#define EGL_NV_stream_dma 1
#define EGL_STREAM_DMA_NV 0x3371
#define EGL_STREAM_DMA_SERVER_NV 0x3372
#endif /* EGL_NV_stream_dma */
#ifndef EGL_NV_stream_fifo_next #ifndef EGL_NV_stream_fifo_next
#define EGL_NV_stream_fifo_next 1 #define EGL_NV_stream_fifo_next 1
#define EGL_PENDING_FRAME_NV 0x3329 #define EGL_PENDING_FRAME_NV 0x3329
...@@ -1205,6 +1236,21 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamMetadataNV (EGLDisplay dpy, EGLStrea ...@@ -1205,6 +1236,21 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamMetadataNV (EGLDisplay dpy, EGLStrea
#endif #endif
#endif /* EGL_NV_stream_metadata */ #endif /* EGL_NV_stream_metadata */
#ifndef EGL_NV_stream_origin
#define EGL_NV_stream_origin 1
#define EGL_STREAM_FRAME_ORIGIN_X_NV 0x3366
#define EGL_STREAM_FRAME_ORIGIN_Y_NV 0x3367
#define EGL_STREAM_FRAME_MAJOR_AXIS_NV 0x3368
#define EGL_CONSUMER_AUTO_ORIENTATION_NV 0x3369
#define EGL_PRODUCER_AUTO_ORIENTATION_NV 0x336A
#define EGL_LEFT_NV 0x336B
#define EGL_RIGHT_NV 0x336C
#define EGL_TOP_NV 0x336D
#define EGL_BOTTOM_NV 0x336E
#define EGL_X_AXIS_NV 0x336F
#define EGL_Y_AXIS_NV 0x3370
#endif /* EGL_NV_stream_origin */
#ifndef EGL_NV_stream_remote #ifndef EGL_NV_stream_remote
#define EGL_NV_stream_remote 1 #define EGL_NV_stream_remote 1
#define EGL_STREAM_STATE_INITIALIZING_NV 0x3240 #define EGL_STREAM_STATE_INITIALIZING_NV 0x3240
...@@ -1301,6 +1347,11 @@ EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void); ...@@ -1301,6 +1347,11 @@ EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void);
#endif /* KHRONOS_SUPPORT_INT64 */ #endif /* KHRONOS_SUPPORT_INT64 */
#endif /* EGL_NV_system_time */ #endif /* EGL_NV_system_time */
#ifndef EGL_NV_triple_buffer
#define EGL_NV_triple_buffer 1
#define EGL_TRIPLE_BUFFER_NV 0x3230
#endif /* EGL_NV_triple_buffer */
#ifndef EGL_TIZEN_image_native_buffer #ifndef EGL_TIZEN_image_native_buffer
#define EGL_TIZEN_image_native_buffer 1 #define EGL_TIZEN_image_native_buffer 1
#define EGL_NATIVE_BUFFER_TIZEN 0x32A0 #define EGL_NATIVE_BUFFER_TIZEN 0x32A0
......
...@@ -212,6 +212,13 @@ struct FeaturesVk : FeatureSetBase ...@@ -212,6 +212,13 @@ struct FeaturesVk : FeatureSetBase
"Some shader compilers don't support sampler arrays as parameters, so revert to old " "Some shader compilers don't support sampler arrays as parameters, so revert to old "
"RewriteStructSamplers behavior, which produces fewer.", "RewriteStructSamplers behavior, which produces fewer.",
&members, "http://anglebug.com/2703"}; &members, "http://anglebug.com/2703"};
// Whether the VkDevice supports the VK_EXT_swapchain_colorspace extension
// http://anglebug.com/2514
Feature supportsSwapchainColorspace = {
"supports_swapchain_colorspace", FeatureCategory::VulkanFeatures,
"VkDevice supports the VK_EXT_swapchain_colorspace extension", &members,
"http://anglebug.com/2514"};
}; };
inline FeaturesVk::FeaturesVk() = default; inline FeaturesVk::FeaturesVk() = default;
......
...@@ -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":
"0eaa5997dff8ebbbc9fc3dd1c9066a85", "78a90e53e3170645d2e24a9998cc7b16",
"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":
"0eaa5997dff8ebbbc9fc3dd1c9066a85", "78a90e53e3170645d2e24a9998cc7b16",
"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":
"0eaa5997dff8ebbbc9fc3dd1c9066a85", "78a90e53e3170645d2e24a9998cc7b16",
"src/libANGLE/gl_enum_utils_autogen.cpp": "src/libANGLE/gl_enum_utils_autogen.cpp":
"ec69c84bb0d44bde62710f5becf9e28d", "ec69c84bb0d44bde62710f5becf9e28d",
"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":
"0eaa5997dff8ebbbc9fc3dd1c9066a85", "78a90e53e3170645d2e24a9998cc7b16",
"scripts/wgl.xml": "scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4", "aa96419c582af2f6673430e2847693f4",
"src/libGL/proc_table_wgl_autogen.cpp": "src/libGL/proc_table_wgl_autogen.cpp":
......
...@@ -128,6 +128,12 @@ supported_egl_extensions = [ ...@@ -128,6 +128,12 @@ supported_egl_extensions = [
"EGL_EXT_platform_device", "EGL_EXT_platform_device",
"EGL_KHR_debug", "EGL_KHR_debug",
"EGL_KHR_fence_sync", "EGL_KHR_fence_sync",
"EGL_KHR_gl_colorspace",
"EGL_EXT_gl_colorspace_display_p3",
"EGL_EXT_gl_colorspace_display_p3_linear",
"EGL_EXT_gl_colorspace_display_p3_passthrough",
"EGL_EXT_gl_colorspace_scrgb",
"EGL_EXT_gl_colorspace_scrgb_linear",
"EGL_KHR_image", "EGL_KHR_image",
"EGL_KHR_no_config_context", "EGL_KHR_no_config_context",
"EGL_KHR_stream", "EGL_KHR_stream",
......
...@@ -1227,6 +1227,12 @@ std::vector<std::string> DisplayExtensions::getStrings() const ...@@ -1227,6 +1227,12 @@ std::vector<std::string> DisplayExtensions::getStrings() const
InsertExtensionString("EGL_KHR_image", image, &extensionStrings); InsertExtensionString("EGL_KHR_image", image, &extensionStrings);
InsertExtensionString("EGL_KHR_image_base", imageBase, &extensionStrings); InsertExtensionString("EGL_KHR_image_base", imageBase, &extensionStrings);
InsertExtensionString("EGL_KHR_image_pixmap", imagePixmap, &extensionStrings); InsertExtensionString("EGL_KHR_image_pixmap", imagePixmap, &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);
InsertExtensionString("EGL_EXT_gl_colorspace_display_p3", glColorspaceDisplayP3, &extensionStrings);
InsertExtensionString("EGL_EXT_gl_colorspace_display_p3_linear", glColorspaceDisplayP3Linear, &extensionStrings);
InsertExtensionString("EGL_EXT_gl_colorspace_display_p3_passthrough", glColorspaceDisplayP3Passthrough, &extensionStrings);
InsertExtensionString("EGL_KHR_gl_texture_2D_image", glTexture2DImage, &extensionStrings); InsertExtensionString("EGL_KHR_gl_texture_2D_image", glTexture2DImage, &extensionStrings);
InsertExtensionString("EGL_KHR_gl_texture_cubemap_image", glTextureCubemapImage, &extensionStrings); InsertExtensionString("EGL_KHR_gl_texture_cubemap_image", glTextureCubemapImage, &extensionStrings);
InsertExtensionString("EGL_KHR_gl_texture_3D_image", glTexture3DImage, &extensionStrings); InsertExtensionString("EGL_KHR_gl_texture_3D_image", glTexture3DImage, &extensionStrings);
......
...@@ -972,6 +972,24 @@ struct DisplayExtensions ...@@ -972,6 +972,24 @@ struct DisplayExtensions
// EGL_ANGLE_swap_with_frame_token // EGL_ANGLE_swap_with_frame_token
bool swapWithFrameToken = false; bool swapWithFrameToken = false;
// EGL_KHR_gl_colorspace
bool glColorspace = false;
// EGL_EXT_gl_colorspace_display_p3_linear
bool glColorspaceDisplayP3Linear = false;
// EGL_EXT_gl_colorspace_display_p3
bool glColorspaceDisplayP3 = false;
// EGL_EXT_gl_colorspace_scrgb
bool glColorspaceScrgb = false;
// EGL_EXT_gl_colorspace_scrgb_linear
bool glColorspaceScrgbLinear = false;
// EGL_EXT_gl_colorspace_display_p3_passthrough
bool glColorspaceDisplayP3Passthrough = false;
}; };
struct DeviceExtensions struct DeviceExtensions
......
...@@ -27,7 +27,7 @@ namespace egl ...@@ -27,7 +27,7 @@ namespace egl
SurfaceState::SurfaceState(const egl::Config *configIn, const AttributeMap &attributesIn) SurfaceState::SurfaceState(const egl::Config *configIn, const AttributeMap &attributesIn)
: label(nullptr), : label(nullptr),
config(configIn), config((configIn != nullptr) ? new egl::Config(*configIn) : nullptr),
attributes(attributesIn), attributes(attributesIn),
timestampsEnabled(false), timestampsEnabled(false),
directComposition(false) directComposition(false)
...@@ -35,7 +35,10 @@ SurfaceState::SurfaceState(const egl::Config *configIn, const AttributeMap &attr ...@@ -35,7 +35,10 @@ SurfaceState::SurfaceState(const egl::Config *configIn, const AttributeMap &attr
directComposition = attributes.get(EGL_DIRECT_COMPOSITION_ANGLE, EGL_FALSE) == EGL_TRUE; directComposition = attributes.get(EGL_DIRECT_COMPOSITION_ANGLE, EGL_FALSE) == EGL_TRUE;
} }
SurfaceState::~SurfaceState() = default; SurfaceState::~SurfaceState()
{
delete config;
}
Surface::Surface(EGLint surfaceType, Surface::Surface(EGLint surfaceType,
const egl::Config *config, const egl::Config *config,
...@@ -148,6 +151,28 @@ void Surface::postSwap(const gl::Context *context) ...@@ -148,6 +151,28 @@ void Surface::postSwap(const gl::Context *context)
Error Surface::initialize(const Display *display) Error Surface::initialize(const Display *display)
{ {
GLenum overrideRenderTargetFormat = mState.config->renderTargetFormat;
// To account for color space differences, override the renderTargetFormat with the
// non-linear format. If no suitable non-linear format was found, return
// EGL_BAD_MATCH error
if (!gl::ColorspaceFormatOverride(mGLColorspace, &overrideRenderTargetFormat))
{
return egl::EglBadMatch();
}
// If an override is required update mState.config as well
if (mState.config->renderTargetFormat != overrideRenderTargetFormat)
{
egl::Config *overrideConfig = new egl::Config(*(mState.config));
overrideConfig->renderTargetFormat = overrideRenderTargetFormat;
delete mState.config;
mState.config = overrideConfig;
mColorFormat = gl::Format(mState.config->renderTargetFormat);
mDSFormat = gl::Format(mState.config->depthStencilFormat);
}
ANGLE_TRY(mImplementation->initialize(display)); ANGLE_TRY(mImplementation->initialize(display));
// Initialized here since impl is nullptr in the constructor. // Initialized here since impl is nullptr in the constructor.
......
...@@ -55,6 +55,58 @@ struct Type ...@@ -55,6 +55,58 @@ struct Type
uint32_t GetPackedTypeInfo(GLenum type); uint32_t GetPackedTypeInfo(GLenum type);
ANGLE_INLINE GLenum GetNonLinearFormat(const GLenum format)
{
switch (format)
{
case GL_BGRA8_EXT:
return GL_BGRA8_SRGB_ANGLEX;
case GL_RGBA8:
return GL_SRGB8_ALPHA8;
case GL_RGB8:
case GL_BGRX8_ANGLEX:
return GL_SRGB8;
case GL_RGBA16F:
return GL_RGBA16F;
default:
return GL_NONE;
}
}
ANGLE_INLINE bool ColorspaceFormatOverride(const EGLenum colorspace, GLenum *rendertargetformat)
{
// Override the rendertargetformat based on colorpsace
switch (colorspace)
{
case EGL_GL_COLORSPACE_LINEAR: // linear colorspace no translation needed
case EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT: // linear colorspace no translation needed
case EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT: // linear colorspace no translation needed
case EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT: // App, not the HW, will specify the
// transfer function
case EGL_GL_COLORSPACE_SCRGB_EXT: // App, not the HW, will specify the transfer function
// No translation
return true;
case EGL_GL_COLORSPACE_SRGB_KHR:
case EGL_GL_COLORSPACE_DISPLAY_P3_EXT:
{
GLenum nonLinearFormat = GetNonLinearFormat(*rendertargetformat);
if (nonLinearFormat != GL_NONE)
{
*rendertargetformat = nonLinearFormat;
return true;
}
else
{
return false;
}
}
break;
default:
UNREACHABLE();
return false;
}
}
ANGLE_INLINE const Type GetTypeInfo(GLenum type) ANGLE_INLINE const Type GetTypeInfo(GLenum type)
{ {
return Type(GetPackedTypeInfo(type)); return Type(GetPackedTypeInfo(type));
......
...@@ -137,6 +137,20 @@ void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const ...@@ -137,6 +137,20 @@ void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
outExtensions->glTexture3DImage = mEGL->hasExtension("EGL_KHR_gl_texture_3D_image"); outExtensions->glTexture3DImage = mEGL->hasExtension("EGL_KHR_gl_texture_3D_image");
outExtensions->glRenderbufferImage = mEGL->hasExtension("EGL_KHR_gl_renderbuffer_image"); outExtensions->glRenderbufferImage = mEGL->hasExtension("EGL_KHR_gl_renderbuffer_image");
outExtensions->glColorspace = mEGL->hasExtension("EGL_KHR_gl_colorspace");
if (outExtensions->glColorspace)
{
outExtensions->glColorspaceDisplayP3Linear =
mEGL->hasExtension("EGL_EXT_gl_colorspace_display_p3_linear");
outExtensions->glColorspaceDisplayP3 =
mEGL->hasExtension("EGL_EXT_gl_colorspace_display_p3");
outExtensions->glColorspaceScrgb = mEGL->hasExtension("EGL_EXT_gl_colorspace_scrgb");
outExtensions->glColorspaceScrgbLinear =
mEGL->hasExtension("EGL_EXT_gl_colorspace_scrgb_linear");
outExtensions->glColorspaceDisplayP3Passthrough =
mEGL->hasExtension("EGL_EXT_gl_colorspace_display_p3_passthrough");
}
outExtensions->imageNativeBuffer = mEGL->hasExtension("EGL_ANDROID_image_native_buffer"); outExtensions->imageNativeBuffer = mEGL->hasExtension("EGL_ANDROID_image_native_buffer");
outExtensions->getFrameTimestamps = mEGL->hasExtension("EGL_ANDROID_get_frame_timestamps"); outExtensions->getFrameTimestamps = mEGL->hasExtension("EGL_ANDROID_get_frame_timestamps");
......
...@@ -26,9 +26,7 @@ WindowSurfaceEGL::~WindowSurfaceEGL() {} ...@@ -26,9 +26,7 @@ WindowSurfaceEGL::~WindowSurfaceEGL() {}
egl::Error WindowSurfaceEGL::initialize(const egl::Display *display) egl::Error WindowSurfaceEGL::initialize(const egl::Display *display)
{ {
constexpr EGLint kForwardedWindowSurfaceAttributes[] = { constexpr EGLint kForwardedWindowSurfaceAttributes[] = {
EGL_RENDER_BUFFER, EGL_RENDER_BUFFER, EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_GL_COLORSPACE};
EGL_POST_SUB_BUFFER_SUPPORTED_NV,
};
native_egl::AttributeVector nativeAttribs = native_egl::AttributeVector nativeAttribs =
native_egl::TrimAttributeMap(mState.attributes, kForwardedWindowSurfaceAttributes); native_egl::TrimAttributeMap(mState.attributes, kForwardedWindowSurfaceAttributes);
......
...@@ -192,6 +192,7 @@ void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const ...@@ -192,6 +192,7 @@ void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const
outExtensions->imageNativeBuffer = outExtensions->imageNativeBuffer =
getRenderer()->getFeatures().supportsAndroidHardwareBuffer.enabled; getRenderer()->getFeatures().supportsAndroidHardwareBuffer.enabled;
outExtensions->surfacelessContext = true; outExtensions->surfacelessContext = true;
outExtensions->glColorspace = getRenderer()->getFeatures().supportsSwapchainColorspace.enabled;
outExtensions->noConfigContext = true; outExtensions->noConfigContext = true;
......
...@@ -718,6 +718,12 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk, ...@@ -718,6 +718,12 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
enabledInstanceExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); enabledInstanceExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
} }
if (ExtensionFound(VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME, instanceExtensionNames))
{
enabledInstanceExtensions.push_back(VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME);
ANGLE_FEATURE_CONDITION((&mFeatures), supportsSwapchainColorspace, true);
}
// Verify the required extensions are in the extension names set. Fail if not. // Verify the required extensions are in the extension names set. Fail if not.
std::sort(enabledInstanceExtensions.begin(), enabledInstanceExtensions.end(), StrLess); std::sort(enabledInstanceExtensions.begin(), enabledInstanceExtensions.end(), StrLess);
ANGLE_VK_TRY(displayVk, ANGLE_VK_TRY(displayVk,
......
...@@ -457,7 +457,14 @@ egl::Error WindowSurfaceVk::initialize(const egl::Display *display) ...@@ -457,7 +457,14 @@ egl::Error WindowSurfaceVk::initialize(const egl::Display *display)
{ {
DisplayVk *displayVk = vk::GetImpl(display); DisplayVk *displayVk = vk::GetImpl(display);
angle::Result result = initializeImpl(displayVk); angle::Result result = initializeImpl(displayVk);
return angle::ToEGL(result, displayVk, EGL_BAD_SURFACE); if (result == angle::Result::Incomplete)
{
return angle::ToEGL(result, displayVk, EGL_BAD_MATCH);
}
else
{
return angle::ToEGL(result, displayVk, EGL_BAD_SURFACE);
}
} }
angle::Result WindowSurfaceVk::initializeImpl(DisplayVk *displayVk) angle::Result WindowSurfaceVk::initializeImpl(DisplayVk *displayVk)
...@@ -549,7 +556,12 @@ angle::Result WindowSurfaceVk::initializeImpl(DisplayVk *displayVk) ...@@ -549,7 +556,12 @@ angle::Result WindowSurfaceVk::initializeImpl(DisplayVk *displayVk)
} }
} }
ANGLE_VK_CHECK(displayVk, foundFormat, VK_ERROR_INITIALIZATION_FAILED); // If a non-linear colorspace was requested but the non-linear format is
// not supported as a vulkan surface format, treat it as a non-fatal error
if (!foundFormat)
{
return angle::Result::Incomplete;
}
} }
mCompositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; mCompositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
...@@ -679,6 +691,29 @@ angle::Result WindowSurfaceVk::newPresentSemaphore(vk::Context *context, ...@@ -679,6 +691,29 @@ angle::Result WindowSurfaceVk::newPresentSemaphore(vk::Context *context,
return angle::Result::Continue; return angle::Result::Continue;
} }
static VkColorSpaceKHR MapEglColorSpaceToVkColorSpace(EGLenum EGLColorspace)
{
switch (EGLColorspace)
{
case EGL_NONE:
case EGL_GL_COLORSPACE_LINEAR:
case EGL_GL_COLORSPACE_SRGB_KHR:
case EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT:
return VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
case EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT:
return VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT;
case EGL_GL_COLORSPACE_DISPLAY_P3_EXT:
return VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT;
case EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT:
return VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT;
case EGL_GL_COLORSPACE_SCRGB_EXT:
return VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT;
default:
UNREACHABLE();
return VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
}
}
angle::Result WindowSurfaceVk::resizeSwapchainImages(vk::Context *context, uint32_t imageCount) angle::Result WindowSurfaceVk::resizeSwapchainImages(vk::Context *context, uint32_t imageCount)
{ {
mSwapchainImages.resize(imageCount); mSwapchainImages.resize(imageCount);
...@@ -729,7 +764,8 @@ angle::Result WindowSurfaceVk::createSwapChain(vk::Context *context, ...@@ -729,7 +764,8 @@ angle::Result WindowSurfaceVk::createSwapChain(vk::Context *context,
swapchainInfo.surface = mSurface; swapchainInfo.surface = mSurface;
swapchainInfo.minImageCount = mMinImageCount; swapchainInfo.minImageCount = mMinImageCount;
swapchainInfo.imageFormat = nativeFormat; swapchainInfo.imageFormat = nativeFormat;
swapchainInfo.imageColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; swapchainInfo.imageColorSpace = MapEglColorSpaceToVkColorSpace(
static_cast<EGLenum>(mState.attributes.get(EGL_GL_COLORSPACE, EGL_NONE)));
// Note: Vulkan doesn't allow 0-width/height swapchains. // Note: Vulkan doesn't allow 0-width/height swapchains.
swapchainInfo.imageExtent.width = std::max(extents.width, 1); swapchainInfo.imageExtent.width = std::max(extents.width, 1);
swapchainInfo.imageExtent.height = std::max(extents.height, 1); swapchainInfo.imageExtent.height = std::max(extents.height, 1);
......
...@@ -558,7 +558,7 @@ egl::Config GenerateDefaultConfig(const RendererVk *renderer, ...@@ -558,7 +558,7 @@ egl::Config GenerateDefaultConfig(const RendererVk *renderer,
config.bindToTextureRGB = colorFormat.format == GL_RGB; config.bindToTextureRGB = colorFormat.format == GL_RGB;
config.bindToTextureRGBA = colorFormat.format == GL_RGBA || colorFormat.format == GL_BGRA_EXT; config.bindToTextureRGBA = colorFormat.format == GL_RGBA || colorFormat.format == GL_BGRA_EXT;
config.colorBufferType = EGL_RGB_BUFFER; config.colorBufferType = EGL_RGB_BUFFER;
config.configCaveat = EGL_NONE; config.configCaveat = GetConfigCaveat(colorFormat.internalFormat);
config.conformant = es2Support | es3Support; config.conformant = es2Support | es3Support;
config.depthSize = depthStencilFormat.depthBits; config.depthSize = depthStencilFormat.depthBits;
config.stencilSize = depthStencilFormat.stencilBits; config.stencilSize = depthStencilFormat.stencilBits;
......
...@@ -51,6 +51,23 @@ egl::ConfigSet GenerateConfigs(const GLenum (&colorFormats)[ColorFormatCount], ...@@ -51,6 +51,23 @@ egl::ConfigSet GenerateConfigs(const GLenum (&colorFormats)[ColorFormatCount],
return GenerateConfigs(colorFormats, ColorFormatCount, depthStencilFormats, return GenerateConfigs(colorFormats, ColorFormatCount, depthStencilFormats,
DepthStencilFormatCount, display); DepthStencilFormatCount, display);
} }
static ANGLE_INLINE EGLenum GetConfigCaveat(GLenum format)
{
// Default EGL config sorting rule will result in rgb10a2 having higher precedence than rgb8
// By marking `rgb10a2` as a slow config we switch the order. This ensures that we dont
// return rgb10a2 at the top of the config list
switch (format)
{
// For now we only mark rgb10a2 as a slow config
case GL_RGB10_A2_EXT:
return EGL_SLOW_CONFIG;
default:
return EGL_NONE;
}
}
} // namespace egl_vk } // namespace egl_vk
namespace vk namespace vk
......
...@@ -134,7 +134,7 @@ egl::Error DisplayVkWin32::initialize(egl::Display *display) ...@@ -134,7 +134,7 @@ egl::Error DisplayVkWin32::initialize(egl::Display *display)
egl::ConfigSet DisplayVkWin32::generateConfigs() egl::ConfigSet DisplayVkWin32::generateConfigs()
{ {
constexpr GLenum kColorFormats[] = {GL_RGB565, GL_BGRA8_EXT, GL_BGRX8_ANGLEX}; constexpr GLenum kColorFormats[] = {GL_RGB565, GL_BGRA8_EXT, GL_BGRX8_ANGLEX, GL_RGB10_A2_EXT};
return egl_vk::GenerateConfigs(kColorFormats, egl_vk::kConfigDepthStencilFormats, this); return egl_vk::GenerateConfigs(kColorFormats, egl_vk::kConfigDepthStencilFormats, this);
} }
......
...@@ -314,6 +314,50 @@ Error ValidateConfigAttributes(const Display *display, const AttributeMap &attri ...@@ -314,6 +314,50 @@ Error ValidateConfigAttributes(const Display *display, const AttributeMap &attri
return NoError(); return NoError();
} }
Error ValidateColorspaceAttribute(const DisplayExtensions &displayExtensions, EGLAttrib colorSpace)
{
switch (colorSpace)
{
case EGL_GL_COLORSPACE_SRGB:
break;
case EGL_GL_COLORSPACE_LINEAR:
break;
case EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT:
if (!displayExtensions.glColorspaceDisplayP3Linear)
{
return EglBadAttribute() << "EXT_gl_colorspace_display_p3_linear is not available.";
}
break;
case EGL_GL_COLORSPACE_DISPLAY_P3_EXT:
if (!displayExtensions.glColorspaceDisplayP3)
{
return EglBadAttribute() << "EXT_gl_colorspace_display_p3 is not available.";
}
break;
case EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT:
if (!displayExtensions.glColorspaceDisplayP3Passthrough)
{
return EglBadAttribute()
<< "EGL_EXT_gl_colorspace_display_p3_passthrough is not available.";
}
break;
case EGL_GL_COLORSPACE_SCRGB_EXT:
if (!displayExtensions.glColorspaceScrgb)
{
return EglBadAttribute() << "EXT_gl_colorspace_scrgb is not available.";
}
break;
case EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT:
if (!displayExtensions.glColorspaceScrgbLinear)
{
return EglBadAttribute() << "EXT_gl_colorspace_scrgb_linear is not available.";
}
break;
default:
return EglBadAttribute();
}
return NoError();
}
Error ValidatePlatformType(const ClientExtensions &clientExtensions, EGLAttrib platformType) Error ValidatePlatformType(const ClientExtensions &clientExtensions, EGLAttrib platformType)
{ {
switch (platformType) switch (platformType)
...@@ -1412,6 +1456,10 @@ Error ValidateCreateWindowSurface(Display *display, ...@@ -1412,6 +1456,10 @@ Error ValidateCreateWindowSurface(Display *display,
case EGL_VG_COLORSPACE: case EGL_VG_COLORSPACE:
return EglBadMatch(); return EglBadMatch();
case EGL_GL_COLORSPACE:
ANGLE_TRY(ValidateColorspaceAttribute(displayExtensions, value));
break;
case EGL_VG_ALPHA_FORMAT: case EGL_VG_ALPHA_FORMAT:
return EglBadMatch(); return EglBadMatch();
...@@ -1511,6 +1559,10 @@ Error ValidateCreatePbufferSurface(Display *display, Config *config, const Attri ...@@ -1511,6 +1559,10 @@ Error ValidateCreatePbufferSurface(Display *display, Config *config, const Attri
case EGL_VG_COLORSPACE: case EGL_VG_COLORSPACE:
break; break;
case EGL_GL_COLORSPACE:
ANGLE_TRY(ValidateColorspaceAttribute(displayExtensions, value));
break;
case EGL_VG_ALPHA_FORMAT: case EGL_VG_ALPHA_FORMAT:
break; break;
......
...@@ -132,7 +132,6 @@ ...@@ -132,7 +132,6 @@
2635 WIN VULKAN : dEQP-EGL.functional.resize.surface_size.grow = FAIL 2635 WIN VULKAN : dEQP-EGL.functional.resize.surface_size.grow = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.resize.surface_size.stretch_height = FAIL 2635 WIN VULKAN : dEQP-EGL.functional.resize.surface_size.stretch_height = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.resize.surface_size.stretch_width = FAIL 2635 WIN VULKAN : dEQP-EGL.functional.resize.surface_size.stretch_width = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.wide_color.pbuffer_8888_colorspace_default = FAIL
2716 WIN VULKAN : dEQP-EGL.functional.preserve_swap.no_preserve.* = FAIL 2716 WIN VULKAN : dEQP-EGL.functional.preserve_swap.no_preserve.* = FAIL
// Linux failures // Linux failures
...@@ -222,7 +221,6 @@ ...@@ -222,7 +221,6 @@
2546 ANDROID VULKAN : dEQP-EGL.functional.query_surface.set_attribute.window.other = SKIP 2546 ANDROID VULKAN : dEQP-EGL.functional.query_surface.set_attribute.window.other = SKIP
2546 ANDROID VULKAN : dEQP-EGL.functional.query_surface.simple.window.other = SKIP 2546 ANDROID VULKAN : dEQP-EGL.functional.query_surface.simple.window.other = SKIP
2546 ANDROID VULKAN : dEQP-EGL.functional.resize.pixel_density.* = SKIP 2546 ANDROID VULKAN : dEQP-EGL.functional.resize.pixel_density.* = SKIP
2546 ANDROID VULKAN : dEQP-EGL.functional.wide_color.window* = SKIP
// Robustness failures on multiple platforms // Robustness failures on multiple platforms
3711 : dEQP-EGL.functional.robustness.reset_context.shaders.out_of_bounds.reset_status.reads.* = FAIL 3711 : dEQP-EGL.functional.robustness.reset_context.shaders.out_of_bounds.reset_status.reads.* = FAIL
......
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