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

EXT_image_dma_buf_import format enumeration #142

Open
emersion opened this issue Nov 27, 2021 · 8 comments
Open

EXT_image_dma_buf_import format enumeration #142

emersion opened this issue Nov 27, 2021 · 8 comments

Comments

@emersion
Copy link

EXT_image_dma_buf_import allows one to import DMA-BUFs, but doesn't allow one to enumerate the list of supported formats. EXT_image_dma_buf_import_modifiers fixes this by adding eglQueryDmaBufFormatsEXT.

The ability to enumerate formats is key for proper format negotiation, e.g. in a Wayland compositor. The latest linux-dmabuf protocol version doesn't allow clients to import DMA-BUFs for formats not advertised by the compositor.

Some drivers don't support modifiers. Because format enumeration is important, Mesa will still advertise EXT_image_dma_buf_import_modifiers for these drivers (and return an empty list in eglQueryDmaBufModifiersEXT).

But none of this is documented anywhere. It would be nice to settle on a solution and add it to the EGL specs. Here are two possible proposals:

  1. Document that drivers supporting EXT_image_dma_buf_import should also support EXT_image_dma_buf_import_modifiers even if they don't support modifiers.
  2. Add a new EXT_image_dma_buf_import_formats extension, which is a subset of EXT_image_dma_buf_import_modifiers: it would contain only eglQueryDmaBufFormatsEXT but not eglQueryDmaBufModifiersEXT. Slightly more work, but if it makes sense to you I'm willing to send patches around.

Thoughts?

cc @cubanismo @fooishbar

@stonesthrow
Copy link
Contributor

stonesthrow commented Nov 29, 2021

Thanks @emersion , I will bring this to GLES/EGL WG , but we will need you/MESA people to craft the work/specs. Just not enough people and bandwidth to support linux platform properly.

@fooishbar
Copy link
Contributor

fooishbar commented Nov 29, 2021

I have a very strong preference for #1. Now that all the modifier entrypoints accept (and queries advertise) DRM_FORMAT_MOD_INVALID, and we've all gone out and typed out support for that exact usecase, I don't see what benefit #2 would bring us.

Suggested addition to EGL_EXT_image_dma_buf_import_modifiers question section:

  1. What if my implementation does not support DRM format modifiers?
    It is strongly recommended that every implementation supporting dmabuf import also implements this extension. DRM_FORMAT_MOD_INVALID is a special modifier token indicating that the exact layout is not known and will be determined by implementation-defined semantics. Platforms not supporting modifiers should implement this extension, advertising only the DRM_FORMAT_MOD_INVALID modifier for every supported format, and accepting only the DRM_FORMAT_MOD_INVALID modifier for EGLImage import.

Suggested addition to EGL_EXT_image_dma_buf_import question section:

  1. How can clients discover the set of supported formats?
    Every driver supporting dmabuf import should implement the EGL_EXT_image_dma_buf_import_modifiers extension, even if they do not support modifiers. This extension adds format-advertisement entrypoints, and as detailed in that extension's question section, DRM_FORMAT_MOD_INVALID is used to implement the same behaviour as without that extension, i.e. that the exact buffer layout is not known and will be determined by implementation-defined semantics.

@emersion
Copy link
Author

emersion commented Dec 1, 2021

This looks like a good idea to me. This would let drivers return an external_only flag for implicit modifiers too, which is useful to know whether rendering to a buffer using this format is possible. This isn't possible if the driver returns zero modifiers.

I'll type up the Mesa patch for this.

@cubanismo
Copy link
Contributor

Are there drivers that don't advertise EGL_EXT_image_dma_buf_import_modifiers but do advertise EXT_image_dma_buf_import? If not, I'd prefer stronger language, e.g., just updating EXT_image_dma_buf_import's dependency section to require EGL_EXT_image_dma_buf_import_modifiers, and modifying Daniel's proposed text above accordingly.

@emersion
Copy link
Author

emersion commented Dec 4, 2021

IIRC the Mali proprietary blob does this? @fooishbar probably knows more.

@fooishbar
Copy link
Contributor

It depends on how the SoC vendor configures it (it’s not a single blob like NV), but a lot of them seem to ship it with dmabuf disabled entirely. I’ve yet to see a build with modifiers in the wild.

github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Dec 11, 2021
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Dec 18, 2021
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Dec 18, 2021
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Dec 19, 2021
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Dec 19, 2021
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Dec 19, 2021
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Dec 25, 2021
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Jan 7, 2022
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Jan 22, 2022
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Jan 23, 2022
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Jan 25, 2022
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Jan 27, 2022
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Jan 28, 2022
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Jan 29, 2022
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Jan 30, 2022
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Feb 1, 2022
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Feb 3, 2022
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Feb 4, 2022
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
github-actions bot pushed a commit to colemickens/wlroots-eglstreams that referenced this issue Feb 10, 2022
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: KhronosGroup/EGL-Registry#142
@shutaozhenzhen
Copy link

Are there drivers that don't advertise EGL_EXT_image_dma_buf_import_modifiers but do advertise EXT_image_dma_buf_import? If not, I'd prefer stronger language, e.g., just updating EXT_image_dma_buf_import's dependency section to require EGL_EXT_image_dma_buf_import_modifiers, and modifying Daniel's proposed text above accordingly.

I meet a soc which use mali G52, and support EXT_image_dma_buf_import, but do not support EGL_EXT_image_dma_buf_import_modifiers. eglQueryDmaBufFormatsEXT actually returns meanful fourcc codes, but only some of the return values are truely supported.

@fooishbar
Copy link
Contributor

I assume this is using the proprietary Mali driver? Exposing the entrypoint without advertising the extension is not something that’s expected to work - and the driver can be trivially modified to work with the modifier extension by exposing only DRM_FORMAT_MOD_INVALID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants