Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add EXT_config_drm_format_query extension #161

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/egl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3528,5 +3528,10 @@
<enum name="EGL_DEVICE_EXT"/>
</require>
</extension>
<extension name="EGL_EXT_config_drm_format_query" supported="egl">
<require>
<enum name="EGL_LINUX_DRM_FOURCC_EXT"/>
</require>
</extension>
</extensions>
</registry>
107 changes: 107 additions & 0 deletions extensions/EXT/EGL_EXT_config_drm_format_query.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
Name

EXT_config_drm_format_query

Name Strings

EGL_EXT_config_drm_format_query

Contributors

Contacts

Austin Shafer, NVIDIA (ashafer 'at' nvidia.com)

Status

Complete.

Version

Version 1 - July 5th, 2022

Number

EGL Extension #149

Extension Type

EGL client extension

Dependencies

Written based on the wording of the EGL 1.5 specification.

This extension inlcudes the enum EGL_LINUX_DRM_FOURCC_EXT as defined in
EGL_EXT_image_dma_buf_import and requires the EGL_KHR_stream extension.

Overview

This extension adds an EGLConfig attribute for stream surface
configurations that specifies a DRM format, as defined in drm_fourcc.h. If
an application needs to share buffers with other libraries or processes
that require specific formats, then this allows an application to select a
matching EGLConfig accordingly. EGLStream applications may need to know
what DRM format a surface is using so that they can pass the format and any
modifiers to other APIs or other stream consumers.

This extension allows passing EGL_LINUX_DRM_FOURCC_EXT to
eglGetConfigAttrib, allowing the application to forward the format code
as needed. This is only valid on EGLConfigs which have the EGL_STREAM_BIT_KHR
appear in the EGL_SURFACE_TYPE attribute.

New Types

None

New Functions

None

New Tokens

Accepted as an attribute in the <attribute> parameter of
eglGetConfigAttrib:

EGL_LINUX_DRM_FOURCC_EXT 0x3271

Changes in section 3.4.3 "Querying Configuration Attributes"

Add EGL_LINUX_DRM_FOURCC_EXT to the attributes accepted by
eglGetConfigAttrib. EGL_LINUX_DRM_FOURCC_EXT specifices a DRM format code
as declared in the Linux drm_fourcc.h header. This is only valid on
EGLConfigs which have the EGL_STREAM_BIT_KHR appear in the EGL_SURFACE_TYPE
attribute.

If EGL_LINUX_DRM_FOURCC_EXT is the attribute being requested and the
EGLConfig does not have a corresponding DRM format, then DRM_FORMAT_INVALID
is returned.

Changes in section 3.4.1 "Querying Configurations"

If EGL_LINUX_DRM_FOURCC_EXT is specified as an attribute in the attrib_list
argument of eglChooseConfig, then it will be ignored when choosing a
config.

Issues

1. Should EGL_LINUX_DRM_FOURCC_EXT be usable as an attribute in eglChooseConfig?

RESOLVED: No, eglChooseConfig should ignore EGL_LINUX_DRM_FOURCC_EXT. We can't
appropriately handle EGL_DONT_CARE due to possible collisions with DRM format
values. Currently there is no DRM format that aliases with EGL_DONT_CARE, but
there is no guarantee that it cannot happen in the future.
Comment on lines +92 to +93
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the only concern causing it to not be usable with eglChooseConfig(), we can simply reserve it upstream and ensure that it never gets used. (Practically speaking it is of zero concern since the upstream FourCC codes are defined in terms of ASCII character codes, and ASCII 255 is not going to pass review, but we can also explicitly reserve it if it would make you more comfortable.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured that the chance of 0xFFFFFFFF being a real format is pretty much zero, but unless it's explicitly reserved, I wouldn't want to count on it never being used for some special meaning.

If we do reserve it upstream, though, then selecting a format with eglChooseConfig should work fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, explicitly reserving 0xFFFFFFFF as a special format token in drm_fourcc.h is probably the cleanest way to resolve this. I was a bit disappointed with the prior resolution.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the consensus is to limit this to EGLStreams, should we still consider going ahead with reserving this upstream? Or should we not bother and stick with the current "reduced/streams-focused" behavior of this extension which doesn't worry about specifying this in eglChooseConfig()? It seems like the later, but I figure we should explicitly decide that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think it'd still be best to explicitly reserve 0xFFFFFFFF in drm_fourcc.h. Probably best to propose that upstream before merging this. I don't know why anyone would object, but you never know.


2. Should this be limited to stream surface configs?

RESOLVED: Yes, considering the only use case for this right now is interactions
with EGLStream applications it doesn't make sense to support it in all cases
and open the door to unintended consequences. If more use cases for this
query operation appear then this restriction can be lifted.


Revision History

#1 (July 5th, 2022) Austin Shafer

- Initial draft
7 changes: 6 additions & 1 deletion registry.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -767,4 +767,9 @@ extension EGL_EXT_explicit_device {
flags public
filename extensions/EXT/EGL_EXT_explicit_device.txt
}
# Next free extension number: 149
extension EGL_EXT_config_drm_format_query {
number 149
flags public
filename extensions/EXT/EGL_EXT_config_drm_format_query
}
# Next free extension number: 150