Re: eglGetDisplay(EGL_DEFAULT_DISPLAY)

Thiago Milczarek SayĆ£o <[email protected]> Tue, 30 Apr 2024 11:49:10 -0300
Newsgroups gmane.comp.video.mesa3d.user
Message-ID <CAAP_wu=Oa03z1w8vZRj5-kK+jitWif3CtW_2PPF1TMYO3xzKsQ@mail.gmail.com>
--000000000000a642820617517937
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Thank you very much, Pekka.


Em ter., 30 de abr. de 2024 =C3=A0s 11:39, Pekka Paalanen <
[email protected]> escreveu:

> On Tue, 30 Apr 2024 09:58:32 -0300
> Thiago Milczarek Say=C3=A3o <[email protected]> wrote:
>
> > Hi,
> >
> > I'm looking the docs at
> > https://registry.khronos.org/EGL/sdk/docs/man/html/eglGetDisplay.xhtml
> >
> > But I'm still in doubt how it actually works, especially on Mesa.
> >
> > Will it detect which platform it's on if I pass EGL_DEFAULT_DISPLAY ? F=
or
> > example, if I want to use the same code for Wayland and X11.
>
> I think Mesa EGL will first look at environment variable EGL_PLATFORM
> for a hard-override of the chosen platform. Otherwise, it tries to
> detect a platform from the native display passed in, which
> EGL_DEFAULT_DISPLAY does not provide. Finally there is a build-time
> chosen fallback.
>
> eglGetDisplay itself is a bit problematic since it was not intended to
> support choosing the platform at runtime (only at EGL implementation
> build time). New code would be better using eglGetPlatformDisplay(EXT)
> if at all possible, especially when you want it to work on multiple
> platforms, or just to be safe that EGL does not guess wrong what kind
> of native display you are passing in. Guessing it wrong would cause
> nonsensical errors or crashes. This is also why using EGL_PLATFORM
> environment variable is not a good idea.
>
> FWIW, on Wayland, EGL_DEFAULT_DISPLAY will not allow you to render into
> a window. It would open a new Wayland connection, but your application
> windows are created through a connection you made yourself, so EGL
> would not be able to target your windows. Each wl_surface is private to
> the connection where it was created.
>
>
> Thanks,
> pq
>

--000000000000a642820617517937
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thank you very much, Pekka.<div><br></div></div><br><div c=
lass=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">Em ter., 30 de a=
br. de 2024 =C3=A0s 11:39, Pekka Paalanen &lt;<a href=3D"mailto:pekka.paala=
[email protected]">[email protected]</a>&gt; escreveu:<br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, 30 Apr 2024 09:58=
:32 -0300<br>
Thiago Milczarek Say=C3=A3o &lt;<a href=3D"mailto:[email protected]" t=
arget=3D"_blank">[email protected]</a>&gt; wrote:<br>
<br>
&gt; Hi,<br>
&gt; <br>
&gt; I&#39;m looking the docs at<br>
&gt; <a href=3D"https://registry.khronos.org/EGL/sdk/docs/man/html/eglGetDi=
splay.xhtml" rel=3D"noreferrer" target=3D"_blank">https://registry.khronos.=
org/EGL/sdk/docs/man/html/eglGetDisplay.xhtml</a><br>
&gt; <br>
&gt; But I&#39;m still in doubt how it actually works, especially on Mesa.<=
br>
&gt; <br>
&gt; Will it detect which platform it&#39;s on if I pass EGL_DEFAULT_DISPLA=
Y ? For<br>
&gt; example, if I want to use the same code for Wayland and X11.<br>
<br>
I think Mesa EGL will first look at environment variable EGL_PLATFORM<br>
for a hard-override of the chosen platform. Otherwise, it tries to<br>
detect a platform from the native display passed in, which<br>
EGL_DEFAULT_DISPLAY does not provide. Finally there is a build-time<br>
chosen fallback.<br>
<br>
eglGetDisplay itself is a bit problematic since it was not intended to<br>
support choosing the platform at runtime (only at EGL implementation<br>
build time). New code would be better using eglGetPlatformDisplay(EXT)<br>
if at all possible, especially when you want it to work on multiple<br>
platforms, or just to be safe that EGL does not guess wrong what kind<br>
of native display you are passing in. Guessing it wrong would cause<br>
nonsensical errors or crashes. This is also why using EGL_PLATFORM<br>
environment variable is not a good idea.<br>
<br>
FWIW, on Wayland, EGL_DEFAULT_DISPLAY will not allow you to render into<br>
a window. It would open a new Wayland connection, but your application<br>
windows are created through a connection you made yourself, so EGL<br>
would not be able to target your windows. Each wl_surface is private to<br>
the connection where it was created.<br>
<br>
<br>
Thanks,<br>
pq<br>
</blockquote></div>

--000000000000a642820617517937--