Re: [Mesa-dev] [PATCH v2 8/8] egl: add EGL_platform_device support

2019-04-04 Thread Mathias Fröhlich
Good morning,

On Wednesday, 3 April 2019 16:51:03 CEST Marek Olšák wrote:
> On Wed, Apr 3, 2019 at 10:13 AM Mathias Fröhlich 
> wrote:
> 
> > > What is missing for merging this?
> >
> > I saw the pbuffer swrast crash and proposed to disable them via the
> > 3rd patch that I pushed into my branch for you.
> > Emil never responded to that proposal directly. In one mail he mentioned
> > that he wanted to care for swrast to cope with the pbuffers. So I hoped
> > that
> > he continues the work he mentioned...
> >
> > For me it would be ok to squash patch #2 and #3 into one and for now
> > disable pbuffers on swrast from device.
> >
> > What I don't want to have is mesa crashing on the egl pbuffer on a swrast
> > device as crashing is not an option.
> >
> 
> Sounds reasonable. So you basically said that the branch is ready to be
> merged, right?

Hmm, Emil sent a new series. I spent the day to plug together all the use
cases that should be tested finally. I just sent that to the piglit list.
With that I hope not to mention anymore /some/ test cases here around
that you don't know. An may be you both take a look at the test so that
we can continuously test these code paths.

I will take a look at Emils changes as my branch only got rebased to
keep it compiling. I am not sure my branch still works sufficiently.

> I'm being pressured to get EGL_EXT_platform_device into master ASAP.
Which I completely understand.
The feature is really a killer feature for the CAE industry!

best

Mathias


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH v2 8/8] egl: add EGL_platform_device support

2019-04-04 Thread Emil Velikov
On Wed, 3 Apr 2019 at 15:51, Marek Olšák  wrote:
>
> On Wed, Apr 3, 2019 at 10:13 AM Mathias Fröhlich  
> wrote:
>>
>> > What is missing for merging this?
>>
>> I saw the pbuffer swrast crash and proposed to disable them via the
>> 3rd patch that I pushed into my branch for you.
>> Emil never responded to that proposal directly. In one mail he mentioned
>> that he wanted to care for swrast to cope with the pbuffers. So I hoped that
>> he continues the work he mentioned...
>>
>> For me it would be ok to squash patch #2 and #3 into one and for now
>> disable pbuffers on swrast from device.
>>
>> What I don't want to have is mesa crashing on the egl pbuffer on a swrast
>> device as crashing is not an option.
>
>
> Sounds reasonable. So you basically said that the branch is ready to be 
> merged, right?
>
> I'm being pressured to get EGL_EXT_platform_device into master ASAP.
>
I will respin the series in a moment with a workaround for the swrast crash.

-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH v2 8/8] egl: add EGL_platform_device support

2019-04-03 Thread Marek Olšák
On Wed, Apr 3, 2019 at 10:13 AM Mathias Fröhlich 
wrote:

> > What is missing for merging this?
>
> I saw the pbuffer swrast crash and proposed to disable them via the
> 3rd patch that I pushed into my branch for you.
> Emil never responded to that proposal directly. In one mail he mentioned
> that he wanted to care for swrast to cope with the pbuffers. So I hoped
> that
> he continues the work he mentioned...
>
> For me it would be ok to squash patch #2 and #3 into one and for now
> disable pbuffers on swrast from device.
>
> What I don't want to have is mesa crashing on the egl pbuffer on a swrast
> device as crashing is not an option.
>

Sounds reasonable. So you basically said that the branch is ready to be
merged, right?

I'm being pressured to get EGL_EXT_platform_device into master ASAP.

Marek
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH v2 8/8] egl: add EGL_platform_device support

2019-04-03 Thread Mathias Fröhlich
> What is missing for merging this?

I saw the pbuffer swrast crash and proposed to disable them via the
3rd patch that I pushed into my branch for you.
Emil never responded to that proposal directly. In one mail he mentioned
that he wanted to care for swrast to cope with the pbuffers. So I hoped that
he continues the work he mentioned...

For me it would be ok to squash patch #2 and #3 into one and for now
disable pbuffers on swrast from device.

What I don't want to have is mesa crashing on the egl pbuffer on a swrast
device as crashing is not an option.

best

Mathias

> 
> Thanks,
> Marek
> 
> On Wed, Apr 3, 2019 at 12:30 AM Mathias Fröhlich 
> wrote:
> 
> > Marek,
> >
> > On Tuesday, 2 April 2019 23:07:50 CEST Marek Olšák wrote:
> > > Do you have a branch with patch 7/8 and 8/8? I'm interested in
> > > EGL_EXT_platform_device on radeonsi.
> >
> > You can take a look at the egl-device-4 branch on
> > https://gitlab.freedesktop.org/frohlich/mesa.git
> > I pushed a rebased and slightly changed wip for you.
> >
> > I have also some more tests in my local piglit as well as separate
> > tests/examples that I initially wrote as an example to make use of the
> > extension.
> > But I have to dig out these first...
> >
> > best
> >
> > Mathias
> >
> > >
> > > Thanks,
> > > Marek
> > >
> > > On Wed, Oct 3, 2018 at 4:36 AM Mathias Fröhlich <
> > mathias.froehl...@gmx.net>
> > > wrote:
> > >
> > > > Hi Emil,
> > > >
> > > > Ok, thanks for picking that up.
> > > >
> > > > On Tuesday, 2 October 2018 12:23:30 CEST Emil Velikov wrote:
> > > > > On Thu, 20 Sep 2018 at 15:13, Mathias Fröhlich
> > > > >  wrote:
> > > > >
> > > > > >
> > > > > > If I replace the above with
> > > > > >
> > > > > >  EGLint surface_type = 0;
> > > > > >  /* Only advertise pbuffer configs for non swrast devices
> > */
> > > > > >  if (dri2_dpy->image_driver)
> > > > > > surface_type = EGL_PBUFFER_BIT;
> > > > > >
> > > > > >  dri2_conf = dri2_add_config(dpy,
> > dri2_dpy->driver_configs[i],
> > > > > >config_count + 1, surface_type, NULL,
> > > > > >visuals[j].rgba_masks);
> > > > > >
> > > > > > then I can easily prohibit the crash that I mentioned when trying
> > to
> > > > > > create a pbuffer surface on the swrast device.
> > > > > > At least I do no longer get a valid pbuffer config from
> > eglChooseConfig
> > > > > > and without that we cannot reach the crashing
> > > > > > dri2_dpy->image_driver->createNewDrawable
> > > > > > call somewhere from eglCreatePbufferSurface anymore.
> > > > > >
> > > > > > Still getting a surface less context on swrast should work...
> > > > > >
> > > > > Issue is that we do not know how to create a "pbuffer only" swrast.
> > > > >
> > > > > Hence one resolves to hacks like the ones we have in
> > > > platform_surfaceless.
> > > > > Effectively pilling hacks upon hacks - see swrast_loader_extensions
> > > > > and "software path w/o DRM.".
> > > > >
> > > > > That said, I'm working on proper solution but since it will take some
> > > > > time to finish/merge I'll drop this and 7/8 for now.
> > > >
> > > >
> > > > That's fine too.
> > > >
> > > > What I wanted to avoid is that people using the extension correctly
> > fail
> > > > with a
> > > > crash in the application when running on mesa.
> > > > Think about it. Thats really bad from an application writers point of
> > view
> > > > as you do all right with checking extensions and that and then the
> > opengl
> > > > stack suddenly crashes.
> > > >
> > > > best
> > > >
> > > > Mathias
> > > >
> > > >
> > > > ___
> > > > mesa-dev mailing list
> > > > mesa-dev@lists.freedesktop.org
> > > > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> > > >
> > >
> >
> >
> >
> >
> >
> 




___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH v2 8/8] egl: add EGL_platform_device support

2019-04-03 Thread Marek Olšák
What is missing for merging this?

Thanks,
Marek

On Wed, Apr 3, 2019 at 12:30 AM Mathias Fröhlich 
wrote:

> Marek,
>
> On Tuesday, 2 April 2019 23:07:50 CEST Marek Olšák wrote:
> > Do you have a branch with patch 7/8 and 8/8? I'm interested in
> > EGL_EXT_platform_device on radeonsi.
>
> You can take a look at the egl-device-4 branch on
> https://gitlab.freedesktop.org/frohlich/mesa.git
> I pushed a rebased and slightly changed wip for you.
>
> I have also some more tests in my local piglit as well as separate
> tests/examples that I initially wrote as an example to make use of the
> extension.
> But I have to dig out these first...
>
> best
>
> Mathias
>
> >
> > Thanks,
> > Marek
> >
> > On Wed, Oct 3, 2018 at 4:36 AM Mathias Fröhlich <
> mathias.froehl...@gmx.net>
> > wrote:
> >
> > > Hi Emil,
> > >
> > > Ok, thanks for picking that up.
> > >
> > > On Tuesday, 2 October 2018 12:23:30 CEST Emil Velikov wrote:
> > > > On Thu, 20 Sep 2018 at 15:13, Mathias Fröhlich
> > > >  wrote:
> > > >
> > > > >
> > > > > If I replace the above with
> > > > >
> > > > >  EGLint surface_type = 0;
> > > > >  /* Only advertise pbuffer configs for non swrast devices
> */
> > > > >  if (dri2_dpy->image_driver)
> > > > > surface_type = EGL_PBUFFER_BIT;
> > > > >
> > > > >  dri2_conf = dri2_add_config(dpy,
> dri2_dpy->driver_configs[i],
> > > > >config_count + 1, surface_type, NULL,
> > > > >visuals[j].rgba_masks);
> > > > >
> > > > > then I can easily prohibit the crash that I mentioned when trying
> to
> > > > > create a pbuffer surface on the swrast device.
> > > > > At least I do no longer get a valid pbuffer config from
> eglChooseConfig
> > > > > and without that we cannot reach the crashing
> > > > > dri2_dpy->image_driver->createNewDrawable
> > > > > call somewhere from eglCreatePbufferSurface anymore.
> > > > >
> > > > > Still getting a surface less context on swrast should work...
> > > > >
> > > > Issue is that we do not know how to create a "pbuffer only" swrast.
> > > >
> > > > Hence one resolves to hacks like the ones we have in
> > > platform_surfaceless.
> > > > Effectively pilling hacks upon hacks - see swrast_loader_extensions
> > > > and "software path w/o DRM.".
> > > >
> > > > That said, I'm working on proper solution but since it will take some
> > > > time to finish/merge I'll drop this and 7/8 for now.
> > >
> > >
> > > That's fine too.
> > >
> > > What I wanted to avoid is that people using the extension correctly
> fail
> > > with a
> > > crash in the application when running on mesa.
> > > Think about it. Thats really bad from an application writers point of
> view
> > > as you do all right with checking extensions and that and then the
> opengl
> > > stack suddenly crashes.
> > >
> > > best
> > >
> > > Mathias
> > >
> > >
> > > ___
> > > mesa-dev mailing list
> > > mesa-dev@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> > >
> >
>
>
>
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH v2 8/8] egl: add EGL_platform_device support

2019-04-02 Thread Mathias Fröhlich
Marek,

On Tuesday, 2 April 2019 23:07:50 CEST Marek Olšák wrote:
> Do you have a branch with patch 7/8 and 8/8? I'm interested in
> EGL_EXT_platform_device on radeonsi.

You can take a look at the egl-device-4 branch on
https://gitlab.freedesktop.org/frohlich/mesa.git
I pushed a rebased and slightly changed wip for you.

I have also some more tests in my local piglit as well as separate
tests/examples that I initially wrote as an example to make use of the 
extension.
But I have to dig out these first...

best

Mathias

> 
> Thanks,
> Marek
> 
> On Wed, Oct 3, 2018 at 4:36 AM Mathias Fröhlich 
> wrote:
> 
> > Hi Emil,
> >
> > Ok, thanks for picking that up.
> >
> > On Tuesday, 2 October 2018 12:23:30 CEST Emil Velikov wrote:
> > > On Thu, 20 Sep 2018 at 15:13, Mathias Fröhlich
> > >  wrote:
> > >
> > > >
> > > > If I replace the above with
> > > >
> > > >  EGLint surface_type = 0;
> > > >  /* Only advertise pbuffer configs for non swrast devices */
> > > >  if (dri2_dpy->image_driver)
> > > > surface_type = EGL_PBUFFER_BIT;
> > > >
> > > >  dri2_conf = dri2_add_config(dpy, dri2_dpy->driver_configs[i],
> > > >config_count + 1, surface_type, NULL,
> > > >visuals[j].rgba_masks);
> > > >
> > > > then I can easily prohibit the crash that I mentioned when trying to
> > > > create a pbuffer surface on the swrast device.
> > > > At least I do no longer get a valid pbuffer config from eglChooseConfig
> > > > and without that we cannot reach the crashing
> > > > dri2_dpy->image_driver->createNewDrawable
> > > > call somewhere from eglCreatePbufferSurface anymore.
> > > >
> > > > Still getting a surface less context on swrast should work...
> > > >
> > > Issue is that we do not know how to create a "pbuffer only" swrast.
> > >
> > > Hence one resolves to hacks like the ones we have in
> > platform_surfaceless.
> > > Effectively pilling hacks upon hacks - see swrast_loader_extensions
> > > and "software path w/o DRM.".
> > >
> > > That said, I'm working on proper solution but since it will take some
> > > time to finish/merge I'll drop this and 7/8 for now.
> >
> >
> > That's fine too.
> >
> > What I wanted to avoid is that people using the extension correctly fail
> > with a
> > crash in the application when running on mesa.
> > Think about it. Thats really bad from an application writers point of view
> > as you do all right with checking extensions and that and then the opengl
> > stack suddenly crashes.
> >
> > best
> >
> > Mathias
> >
> >
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >
> 




___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH v2 8/8] egl: add EGL_platform_device support

2019-04-02 Thread Marek Olšák
Do you have a branch with patch 7/8 and 8/8? I'm interested in
EGL_EXT_platform_device on radeonsi.

Thanks,
Marek

On Wed, Oct 3, 2018 at 4:36 AM Mathias Fröhlich 
wrote:

> Hi Emil,
>
> Ok, thanks for picking that up.
>
> On Tuesday, 2 October 2018 12:23:30 CEST Emil Velikov wrote:
> > On Thu, 20 Sep 2018 at 15:13, Mathias Fröhlich
> >  wrote:
> >
> > >
> > > If I replace the above with
> > >
> > >  EGLint surface_type = 0;
> > >  /* Only advertise pbuffer configs for non swrast devices */
> > >  if (dri2_dpy->image_driver)
> > > surface_type = EGL_PBUFFER_BIT;
> > >
> > >  dri2_conf = dri2_add_config(dpy, dri2_dpy->driver_configs[i],
> > >config_count + 1, surface_type, NULL,
> > >visuals[j].rgba_masks);
> > >
> > > then I can easily prohibit the crash that I mentioned when trying to
> > > create a pbuffer surface on the swrast device.
> > > At least I do no longer get a valid pbuffer config from eglChooseConfig
> > > and without that we cannot reach the crashing
> > > dri2_dpy->image_driver->createNewDrawable
> > > call somewhere from eglCreatePbufferSurface anymore.
> > >
> > > Still getting a surface less context on swrast should work...
> > >
> > Issue is that we do not know how to create a "pbuffer only" swrast.
> >
> > Hence one resolves to hacks like the ones we have in
> platform_surfaceless.
> > Effectively pilling hacks upon hacks - see swrast_loader_extensions
> > and "software path w/o DRM.".
> >
> > That said, I'm working on proper solution but since it will take some
> > time to finish/merge I'll drop this and 7/8 for now.
>
>
> That's fine too.
>
> What I wanted to avoid is that people using the extension correctly fail
> with a
> crash in the application when running on mesa.
> Think about it. Thats really bad from an application writers point of view
> as you do all right with checking extensions and that and then the opengl
> stack suddenly crashes.
>
> best
>
> Mathias
>
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH v2 8/8] egl: add EGL_platform_device support

2018-10-03 Thread Mathias Fröhlich
Hi Emil,

Ok, thanks for picking that up.

On Tuesday, 2 October 2018 12:23:30 CEST Emil Velikov wrote:
> On Thu, 20 Sep 2018 at 15:13, Mathias Fröhlich
>  wrote:
> 
> >
> > If I replace the above with
> >
> >  EGLint surface_type = 0;
> >  /* Only advertise pbuffer configs for non swrast devices */
> >  if (dri2_dpy->image_driver)
> > surface_type = EGL_PBUFFER_BIT;
> >
> >  dri2_conf = dri2_add_config(dpy, dri2_dpy->driver_configs[i],
> >config_count + 1, surface_type, NULL,
> >visuals[j].rgba_masks);
> >
> > then I can easily prohibit the crash that I mentioned when trying to
> > create a pbuffer surface on the swrast device.
> > At least I do no longer get a valid pbuffer config from eglChooseConfig
> > and without that we cannot reach the crashing
> > dri2_dpy->image_driver->createNewDrawable
> > call somewhere from eglCreatePbufferSurface anymore.
> >
> > Still getting a surface less context on swrast should work...
> >
> Issue is that we do not know how to create a "pbuffer only" swrast.
> 
> Hence one resolves to hacks like the ones we have in platform_surfaceless.
> Effectively pilling hacks upon hacks - see swrast_loader_extensions
> and "software path w/o DRM.".
> 
> That said, I'm working on proper solution but since it will take some
> time to finish/merge I'll drop this and 7/8 for now.


That's fine too.

What I wanted to avoid is that people using the extension correctly fail with a
crash in the application when running on mesa.
Think about it. Thats really bad from an application writers point of view
as you do all right with checking extensions and that and then the opengl
stack suddenly crashes.

best

Mathias


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 8/8] egl: add EGL_platform_device support

2018-10-02 Thread Emil Velikov
On Thu, 20 Sep 2018 at 15:13, Mathias Fröhlich
 wrote:

>
> If I replace the above with
>
>  EGLint surface_type = 0;
>  /* Only advertise pbuffer configs for non swrast devices */
>  if (dri2_dpy->image_driver)
> surface_type = EGL_PBUFFER_BIT;
>
>  dri2_conf = dri2_add_config(dpy, dri2_dpy->driver_configs[i],
>config_count + 1, surface_type, NULL,
>visuals[j].rgba_masks);
>
> then I can easily prohibit the crash that I mentioned when trying to
> create a pbuffer surface on the swrast device.
> At least I do no longer get a valid pbuffer config from eglChooseConfig
> and without that we cannot reach the crashing
> dri2_dpy->image_driver->createNewDrawable
> call somewhere from eglCreatePbufferSurface anymore.
>
> Still getting a surface less context on swrast should work...
>
Issue is that we do not know how to create a "pbuffer only" swrast.

Hence one resolves to hacks like the ones we have in platform_surfaceless.
Effectively pilling hacks upon hacks - see swrast_loader_extensions
and "software path w/o DRM.".

That said, I'm working on proper solution but since it will take some
time to finish/merge I'll drop this and 7/8 for now.

Thanks
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 8/8] egl: add EGL_platform_device support

2018-09-20 Thread Mathias Fröhlich
Hi Emil,

some comments below:

On Tuesday, 4 September 2018 20:33:05 CEST Emil Velikov wrote:
> From: Emil Velikov 
> 
> This new 'platform' is added by default with no guards.
> 
> It is effectively a copy of the surfaceless one, with updated function
> names and brand new probe function.
> 
> Due to the reuse, some of the ifdef HAVE_SURFACELESS_PLATFORM guards
> have been dropped.
> 
> A worthy mention are the changes in _egFindDisplay, since the original
> and dup'd fd are required, we make use of the plat_opt argument.
> 
> Note that no hacks for eglGetDisplay are added - the API works only with
> the eglGetPlatformDisplay* API.
> 
> v2:
>  - s/_eglCompareDeviceDisplay/_eglSameDeviceDisplay/ (Eric)
>  - let ^^ return bool (Eric)
>  - fixup meson build, move files() further up (Eric)
>  - copy from plat. surfaceless w/o the visual cleanups
>  - close and free when destroying the dpy
>  - sprinkle a few _eglDeviceSupports
>  - split fd handling into separate function
>  - use directly the render node if no FD is given (Mathias)
> 
> Signed-off-by: Emil Velikov 
> ---
> TODO/XXX:
>  - fold/reuse more of surfaceless
>  - swrast is hacky/broken - needs some DRI changes that I'm working atm.
>  - remove local define
> ---
>  src/egl/Makefile.am|   3 +
>  src/egl/drivers/dri2/egl_dri2.c|   3 +
>  src/egl/drivers/dri2/egl_dri2.h|  13 +-
>  src/egl/drivers/dri2/platform_device.c | 398 +
>  src/egl/main/eglapi.c  |  13 +-
>  src/egl/main/egldisplay.c  | 112 ++-
>  src/egl/main/egldisplay.h  |  11 +
>  src/egl/main/eglglobals.c  |   1 +
>  src/egl/meson.build|   1 +
>  9 files changed, 543 insertions(+), 12 deletions(-)
>  create mode 100644 src/egl/drivers/dri2/platform_device.c
> 
> diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am
> index bf7f87015b7..6699f4ea003 100644
> --- a/src/egl/Makefile.am
> +++ b/src/egl/Makefile.am
> @@ -107,6 +107,9 @@ if HAVE_PLATFORM_SURFACELESS
>  dri2_backend_FILES += drivers/dri2/platform_surfaceless.c
>  endif
>  
> +# Unconditionally enable platform_device
> +dri2_backend_FILES += drivers/dri2/platform_device.c
> +
>  if HAVE_PLATFORM_ANDROID
>  AM_CFLAGS += $(ANDROID_CFLAGS)
>  libEGL_common_la_LIBADD += $(ANDROID_LIBS)
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index c5fa935657e..7c2521f120f 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -904,6 +904,9 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
> case _EGL_PLATFORM_SURFACELESS:
>ret = dri2_initialize_surfaceless(drv, disp);
>break;
> +   case _EGL_PLATFORM_DEVICE:
> +  ret = dri2_initialize_device(drv, disp);
> +  break;
> case _EGL_PLATFORM_X11:
>ret = dri2_initialize_x11(drv, disp);
>break;
> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
> index 4abe1ba1952..1a08b2dfdcc 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -330,10 +330,10 @@ struct dri2_egl_surface
> } color_buffers[3], *back;
>  #endif
>  
> -#if defined(HAVE_SURFACELESS_PLATFORM)
> -  __DRIimage   *front;
> -  unsigned int visual;
> -#endif
> +   /* surfaceless and device */
> +   __DRIimage   *front;
> +   unsigned int visual;
> +
> int out_fence_fd;
> EGLBoolean enable_out_fence;
>  };
> @@ -489,6 +489,11 @@ dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay 
> *disp)
>  }
>  #endif
>  
> +EGLBoolean
> +dri2_initialize_device(_EGLDriver *drv, _EGLDisplay *disp);
> +static inline void
> +dri2_teardown_device(struct dri2_egl_display *dri2_dpy) { /* noop */ }
> +
>  void
>  dri2_flush_drawable_for_swapbuffers(_EGLDisplay *disp, _EGLSurface *draw);
>  
> diff --git a/src/egl/drivers/dri2/platform_device.c 
> b/src/egl/drivers/dri2/platform_device.c
> new file mode 100644
> index 000..15d69cedfd0
> --- /dev/null
> +++ b/src/egl/drivers/dri2/platform_device.c
> @@ -0,0 +1,398 @@
> +/*
> + * Mesa 3-D graphics library
> + *
> + * Copyright 2018 Collabora
> + *
> + * Based on platform_surfaceless, which has:
> + *
> + * Copyright (c) 2014 The Chromium OS Authors.
> + * Copyright © 2011 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included
> + * in all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS 

[Mesa-dev] [PATCH v2 8/8] egl: add EGL_platform_device support

2018-09-04 Thread Emil Velikov
From: Emil Velikov 

This new 'platform' is added by default with no guards.

It is effectively a copy of the surfaceless one, with updated function
names and brand new probe function.

Due to the reuse, some of the ifdef HAVE_SURFACELESS_PLATFORM guards
have been dropped.

A worthy mention are the changes in _egFindDisplay, since the original
and dup'd fd are required, we make use of the plat_opt argument.

Note that no hacks for eglGetDisplay are added - the API works only with
the eglGetPlatformDisplay* API.

v2:
 - s/_eglCompareDeviceDisplay/_eglSameDeviceDisplay/ (Eric)
 - let ^^ return bool (Eric)
 - fixup meson build, move files() further up (Eric)
 - copy from plat. surfaceless w/o the visual cleanups
 - close and free when destroying the dpy
 - sprinkle a few _eglDeviceSupports
 - split fd handling into separate function
 - use directly the render node if no FD is given (Mathias)

Signed-off-by: Emil Velikov 
---
TODO/XXX:
 - fold/reuse more of surfaceless
 - swrast is hacky/broken - needs some DRI changes that I'm working atm.
 - remove local define
---
 src/egl/Makefile.am|   3 +
 src/egl/drivers/dri2/egl_dri2.c|   3 +
 src/egl/drivers/dri2/egl_dri2.h|  13 +-
 src/egl/drivers/dri2/platform_device.c | 398 +
 src/egl/main/eglapi.c  |  13 +-
 src/egl/main/egldisplay.c  | 112 ++-
 src/egl/main/egldisplay.h  |  11 +
 src/egl/main/eglglobals.c  |   1 +
 src/egl/meson.build|   1 +
 9 files changed, 543 insertions(+), 12 deletions(-)
 create mode 100644 src/egl/drivers/dri2/platform_device.c

diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am
index bf7f87015b7..6699f4ea003 100644
--- a/src/egl/Makefile.am
+++ b/src/egl/Makefile.am
@@ -107,6 +107,9 @@ if HAVE_PLATFORM_SURFACELESS
 dri2_backend_FILES += drivers/dri2/platform_surfaceless.c
 endif
 
+# Unconditionally enable platform_device
+dri2_backend_FILES += drivers/dri2/platform_device.c
+
 if HAVE_PLATFORM_ANDROID
 AM_CFLAGS += $(ANDROID_CFLAGS)
 libEGL_common_la_LIBADD += $(ANDROID_LIBS)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index c5fa935657e..7c2521f120f 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -904,6 +904,9 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
case _EGL_PLATFORM_SURFACELESS:
   ret = dri2_initialize_surfaceless(drv, disp);
   break;
+   case _EGL_PLATFORM_DEVICE:
+  ret = dri2_initialize_device(drv, disp);
+  break;
case _EGL_PLATFORM_X11:
   ret = dri2_initialize_x11(drv, disp);
   break;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 4abe1ba1952..1a08b2dfdcc 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -330,10 +330,10 @@ struct dri2_egl_surface
} color_buffers[3], *back;
 #endif
 
-#if defined(HAVE_SURFACELESS_PLATFORM)
-  __DRIimage   *front;
-  unsigned int visual;
-#endif
+   /* surfaceless and device */
+   __DRIimage   *front;
+   unsigned int visual;
+
int out_fence_fd;
EGLBoolean enable_out_fence;
 };
@@ -489,6 +489,11 @@ dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay 
*disp)
 }
 #endif
 
+EGLBoolean
+dri2_initialize_device(_EGLDriver *drv, _EGLDisplay *disp);
+static inline void
+dri2_teardown_device(struct dri2_egl_display *dri2_dpy) { /* noop */ }
+
 void
 dri2_flush_drawable_for_swapbuffers(_EGLDisplay *disp, _EGLSurface *draw);
 
diff --git a/src/egl/drivers/dri2/platform_device.c 
b/src/egl/drivers/dri2/platform_device.c
new file mode 100644
index 000..15d69cedfd0
--- /dev/null
+++ b/src/egl/drivers/dri2/platform_device.c
@@ -0,0 +1,398 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright 2018 Collabora
+ *
+ * Based on platform_surfaceless, which has:
+ *
+ * Copyright (c) 2014 The Chromium OS Authors.
+ * Copyright © 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,