Branch
Hash :
7b1b8a01
Author :
Date :
2023-09-21T20:15:29
Metal: Allow using GL_RGB with either RGBA/BGRA IOSurface. Previously we only allowed GL_RGB internal format to be used with BGRA IOSurface and GL_RGBX8_ANGLE to be used with RGBA IOSurface respectively. However, there are currently many places in Chrome prefer GL_RGB to be able to be used with both RGBA and BGRA IOSurface. This CL allows such combinations. Instead of deducing angle::FormatID of the IOSurface pbuffer based on the input GL internal format & type, we will take into account the pixel format of the IOSurface as well. For example, when we call eglCreatePbufferFromClientBuffer with GL_RGB internal format attribute: - if IOSurface's pixel format is 'RGBA' -> deduced angle::FormatID is R8G8B8A8_UNORM. - if IOSurface's pixel format is 'BGRA' -> deduced angle::FormatID is B8G8R8A8_UNORM. This CL also removes GL_RGBX8_ANGLE support from Metal backend. Because there are many places in Chrome that use this format enum for both RGBA & BGRA IOSurface when the extension is available. It's redundant to support that since GL_RGB already covers most of the required cases. Bug: angleproject:8350 Change-Id: I5a121a97e031a42d0779721d4348f373dfaee9a0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4881742 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Quyen Le <lehoangquyen@chromium.org> Reviewed-by: Sunny Sachanandani <sunnyps@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
Name
ANGLE_iosurface_client_buffer
Name Strings
EGL_ANGLE_iosurface_client_buffer
Contributors
Corentin Wallez
Geoff Lang
James Darpinian
Le Hoang Quyen
Contacts
Corentin Wallez, Google Inc. (cwallez 'at' google.com)
Status
Draft
Version
Version 6, Aug 25, 2020
Number
EGL Extension #??
Dependencies
This extension is written against the wording of the EGL 1.4
Specification.
Overview
This extension allows creating EGL surfaces from IOSurface objects.
New Types
None
New Procedures and Functions
None
New Tokens
Accepted in the <buftype> parameter of eglCreatePbufferFromClientBuffer:
EGL_IOSURFACE_ANGLE 0x3454
EGL_IOSURFACE_PLANE_ANGLE 0x345A
EGL_TEXTURE_RECTANGLE_ANGLE 0x345B
EGL_TEXTURE_TYPE_ANGLE 0x345C
EGL_TEXTURE_INTERNAL_FORMAT_ANGLE 0x345D
EGL_IOSURFACE_USAGE_HINT_ANGLE 0x348A
Accepted in the <attribute> parameter of
eglGetConfigAttrib:
EGL_BIND_TO_TEXTURE_TARGET_ANGLE 0x348D
Additions to Chapter 3 of the EGL 1.4 Specification (EGL Functions and Errors)
Replace the last sentence of paragraph 1 of Section 3.5.3 with the
following text.
"Currently, the only client API resources which may be bound in this
fashion are OpenVG VGImage objects and IOSurface objects."
Replace the third paragraph of Section 3.5.3 with the following text.
"<buftype> specifies the type of buffer to be bound. The only allowed values
of <buftype> are EGL_OPENVG_IMAGE and EGL_IOSURFACE_ANGLE".
Append the following text to the fourth paragraph of Section 3.5.3.
"When <buftype> is EGL_IOSURFACE_ANGLE, <buffer> must be a valid IOSurface
object case into the type EGLClientBuffer."
Append to the end of Section 3.5.3.
"When <buftype> is EGL_IOSURFACE_ANGLE, <attrib_list> must contain all the
following attributes otherwise EGL_BAD_PARAMETER is generated. The
attributes must satisfy the following constraints otherwise
EGL_BAD_ATTRIBUTE is generated:
- EGL_TEXTURE_TYPE_ANGLE, and EGL_TEXTURE_INTERNAL_FORMAT_ANGLE followed
by OpenGL enums for texture types, and texture internal format
respectively.
- EGL_TEXTURE_FORMAT with a value of EGL_TEXTURE_RGBA
- EGL_WIDTH with a value between 1 and the width of <buffer>.
- EGL_HEIGHT with a value between 1 and the height of <buffer>.
- EGL_TEXTURE_TARGET with a value that matches the attribute
EGL_BIND_TO_TEXTURE_TARGET_ANGLE as queried from eglGetConfigAttrib.
- EGL_IOSURFACE_PLANE_ANGLE with a value between 0 and the number of
planes of <buffer> (exclusive).
In addition the EGL_TEXTURE_TYPE_ANGLE and
EGL_TEXTURE_INTERNAL_FORMAT_ANGLE attributes must be one of the
combinations listed in table egl.iosurface.formats or an
EGL_BAD_PARAMETER is generated. The combination must also be a valid
combinations for glTexImage2D or EGL_BAD_PARAMETER is generated.
The attribute EGL_IOSURFACE_USAGE_HINT_ANGLE may optionally be specified as
a combination of the bits EGL_IOSURFACE_READ_HINT_ANGLE and
EGL_IOSURFACE_WRITE_HINT_ANGLE. On the iOS Simulator platform, where
IOSurface support is incomplete, these hints indicate whether the intent is
to read from the IOSurface, write to it, or both. Explicitly passing 0 for
this attribute is equivalent to setting both the read and write usage
bits. This attribute is ignored on other platforms."
---------------------------------------------------------------------------
Texture Type Texture Internal Format
---------------------------------------------------------------------------
GL_UNSIGNED_BYTE GL_RED
GL_UNSIGNED_SHORT GL_RED
GL_UNSIGNED_SHORT GL_R16UI
GL_UNSIGNED_BYTE GL_RG
GL_UNSIGNED_SHORT GL_RG
GL_UNSIGNED_BYTE GL_RGB
GL_UNSIGNED_BYTE GL_RGBA
GL_UNSIGNED_BYTE GL_BGRA_EXT
GL_UNSIGNED_INT_2_10_10_10_REV GL_RGB10_A2
GL_HALF_FLOAT GL_RGBA
---------------------------------------------------------------------------
Table egl.iosurface.formats - Valid combinations of format, type and
internal format for IOSurface-backed pbuffers.
---------------------------------------------------------------------------
Append to the end of Section 3.5.3.
"When a pbuffer is created with type EGL_IOSURFACE_ANGLE, the contents
of the associcated IOSurface object are undefined while the pbuffer is
bound to a client texture."
Append to the end of Table 3.1.
---------------------------------------------------------------------------
Attribute Type Notes
---------------------------------------------------------------------------
EGL_BIND_TO_TEXTURE_TARGET_ANGLE enum Texture target supported by
IOSurface-backed pbuffers.
---------------------------------------------------------------------------
Issues
1. Can RGB formats be supported?
RESOLVED: Support for RGB internal formats is added in version 3. Surfaces
with an RGB format will ensure that the alpha channel of the IOSurface is
reset to 1.0 when it is used.
Revision History
Version 1, 2017/12/06 - first draft.
Version 2, 2019/04/01 - Allow MakeCurrent.
Version 3, 2019/08/13 - Allow RGB internal formats
Version 4, 2019/12/28 - Add usage hint; require TEXTURE_RECTANGLE on macOS
and TEXTURE_2D on iOS
Version 5, 2020/06/30 - Allow RGB10_A2 internal formats
Version 6, 2020/08/25 - Allow R16 and RG16 formats for P010 surfaces
Version 7, 2023/09/19 - Allow RGBA/RGBX surfaces