Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out fence

2017-09-08 Thread Marathe, Yogesh
> -Original Message-
> From: Emil Velikov [mailto:emil.l.veli...@gmail.com]
> Sent: Friday, September 8, 2017 11:03 PM
> To: Antognolli, Rafael 
> >> > > Isn't this strange? Can someone please comment?
> >> > >
> >> > In all fairness there was a few wtf moments as Mark mentioned the
> >> > issue. As on a quick look "it cannot happen" :-\
> >> >
> >> > One way is to add some printfs "debugging" across the board and
> >> > check with Mark if he can run (only?) the affected test on the CI.
> >> >
> >>
> >> Number of tests failing on CI due to this are huge, any 'one' can be
> >> picked up. I do have my CI branch setup now but I don’t think I can
> >> use it for debugging (not advised).  I'll sync up with Mark again. Just 
> >> wanted a
> confirmation, I'm not missing something obvious. Thanks.
> >
> > Hi Yogesh,
> >
> > I replied to you already when you messaged in private, the error is
> > not related to the kernel returning true for that, it's related to a
> > memory corruption caused by wrong use of the dri2_surf_init inside
> > platform_x11_dri3.c. Quoting myself:
> >
> > "More specifically, it looks like this test fails every time:
> >
> > glcts -n
> > dEQP-EGL.functional.query_context.get_current_context.rgb888_window
> >

This passes for me. That’s what confused me again. how is that possible?

Output:

Writing test log into TestResults.qpa
dEQP Core git-dfcb8e870438f6f2bfe71d4bb63d43120debb3a3 (0xdfcb8e87) starting..
  target implementation = 'X11 EGL'

Test case 
'dEQP-EGL.functional.query_context.get_current_context.rgb888_window'..
  Pass (Pass)

DONE!

Test run totals:
  Passed:1/1 (100.0%)
  Failed:0/1 (0.0%)
  Not supported: 0/1 (0.0%)
  Warnings:  0/1 (0.0%)

> > I see several valgrind warnings inside platform_x11_dri3.c. I believe
> > you are probably accessing the dri2_surf before it was allocated, or
> > after it was freed..."
> >
> > When I tested this back then, the "out_fence_enable" (or whatever was
> > called) in dri2 was false, but after a couple runs it would become a
> > bogus number, which also points to memory corruption.
> >
> > I suggest ignoring the kernel and focusing on valgrind debugging.
> >
> Nicely spotted there Rafael.
> 
> The issue is that the dri3 surface primitive wraps around _EGLSurface.
> Thus as we reference the new variables we effectively write onto the
> loader_dri3 bits. And at a later stage the dri3 loader code toggles those to 
> "use
> out fence = true".

I will check this with valgrind.

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


Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out fence

2017-09-08 Thread Emil Velikov
On 8 September 2017 at 17:54, Rafael Antognolli
<rafael.antogno...@intel.com> wrote:
> On Fri, Sep 08, 2017 at 08:32:05AM -0700, Marathe, Yogesh wrote:
>> > -Original Message-
>> > From: Emil Velikov [mailto:emil.l.veli...@gmail.com]
>> > Sent: Friday, September 8, 2017 8:28 PM
>> > To: Marathe, Yogesh <yogesh.mara...@intel.com>
>> > Cc: Tomasz Figa <tf...@chromium.org>; Antognolli, Rafael
>> > <rafael.antogno...@intel.com>; Janes, Mark A <mark.a.ja...@intel.com>;
>> > mesa-dev@lists.freedesktop.org; Gao, Shuo <shuo@intel.com>; Liu,
>> > Zhiquan <zhiquan@intel.com>; dani...@collabora.com;
>> > nicolai.haeh...@amd.com; e...@engestrom.ch; Wu, Zhongmin
>> > <zhongmin...@intel.com>; kenn...@whitecape.org; Kondapally, Kalyan
>> > <kalyan.kondapa...@intel.com>; fernetme...@online.de;
>> > tarc...@itsqueeze.com; varad.gau...@collabora.com
>> > Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out
>> > fence
>> >
>> > On 8 September 2017 at 14:47, Marathe, Yogesh <yogesh.mara...@intel.com>
>> > wrote:
>> > > Hello Folks,
>> > >
>> > > Sorry for late reply, I took quite some time to CTS up, comments below.
>> > >
>> > >> -Original Message-
>> > >> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
>> > >> Behalf Of Marathe, Yogesh
>> > >> Sent: Friday, September 1, 2017 10:16 AM
>> > >> To: Tomasz Figa <tf...@chromium.org>
>> > >> Cc: Gao, Shuo <shuo@intel.com>; Liu, Zhiquan
>> > >> <zhiquan@intel.com>; dani...@collabora.com;
>> > >> nicolai.haeh...@amd.com; Antognolli, Rafael
>> > >> <rafael.antogno...@intel.com>; e...@engestrom.ch; Emil Velikov
>> > >> <emil.l.veli...@gmail.com>; Wu, Zhongmin <zhongmin...@intel.com>;
>> > >> kenn...@whitecape.org; Kondapally, Kalyan
>> > >> <kalyan.kondapa...@intel.com>; fernetme...@online.de;
>> > >> mesa-dev@lists.freedesktop.org; tarc...@itsqueeze.com;
>> > >> varad.gau...@collabora.com
>> > >> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per
>> > >> surface out fence
>> > >>
>> > >> Tomasz,
>> > >>
>> > >> > -Original Message-
>> > >> > From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
>> > >> > Behalf Of Tomasz Figa
>> > >> > Sent: Friday, September 1, 2017 9:53 AM
>> > >> > To: Marathe, Yogesh <yogesh.mara...@intel.com> On Thu, Aug 31, 2017
>> > >> > at 2:18 AM, Marathe, Yogesh <yogesh.mara...@intel.com> wrote:
>> > >> > >> -Original Message-
>> > >> > >> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org]
>> > >> > >> On Behalf Of Emil Velikov
>> > >> > >> Sent: Wednesday, August 30, 2017 9:44 PM
>> > >> > >> To: Marathe, Yogesh <yogesh.mara...@intel.com>
>> > >> > >> Cc: Gao, Shuo <shuo@intel.com>; Liu, Zhiquan
>> > >> > >> <zhiquan@intel.com>; dani...@collabora.com;
>> > >> > >> nicolai.haeh...@amd.com; Antognolli, Rafael
>> > >> > >> <rafael.antogno...@intel.com>; e...@engestrom.ch; Wu, Zhongmin
>> > >> > >> <zhongmin...@intel.com>; tf...@chromium.org;
>> > >> kenn...@whitecape.org;
>> > >> > >> Kondapally, Kalyan <kalyan.kondapa...@intel.com>;
>> > >> > >> fernetme...@online.de; mesa-dev@lists.freedesktop.org;
>> > >> > >> tarc...@itsqueeze.com; varad.gau...@collabora.com
>> > >> > >> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per
>> > >> > >> surface out fence
>> > >> > >>
>> > >> > >> On 30 August 2017 at 15:39, Marathe, Yogesh
>> > >> > >> <yogesh.mara...@intel.com>
>> > >> > >> wrote:
>> > >> > >>
>> > >> > >> >
>> > >> > >> > Thank you, Tomasz and all involved for the help and guidance.
>> > >> > >> >
>> > >> > >> Our excitement was short lived - see commit
>> > >&g

Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out fence

2017-09-08 Thread Rafael Antognolli
On Fri, Sep 08, 2017 at 08:32:05AM -0700, Marathe, Yogesh wrote:
> > -Original Message-
> > From: Emil Velikov [mailto:emil.l.veli...@gmail.com]
> > Sent: Friday, September 8, 2017 8:28 PM
> > To: Marathe, Yogesh <yogesh.mara...@intel.com>
> > Cc: Tomasz Figa <tf...@chromium.org>; Antognolli, Rafael
> > <rafael.antogno...@intel.com>; Janes, Mark A <mark.a.ja...@intel.com>;
> > mesa-dev@lists.freedesktop.org; Gao, Shuo <shuo@intel.com>; Liu,
> > Zhiquan <zhiquan@intel.com>; dani...@collabora.com;
> > nicolai.haeh...@amd.com; e...@engestrom.ch; Wu, Zhongmin
> > <zhongmin...@intel.com>; kenn...@whitecape.org; Kondapally, Kalyan
> > <kalyan.kondapa...@intel.com>; fernetme...@online.de;
> > tarc...@itsqueeze.com; varad.gau...@collabora.com
> > Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out
> > fence
> > 
> > On 8 September 2017 at 14:47, Marathe, Yogesh <yogesh.mara...@intel.com>
> > wrote:
> > > Hello Folks,
> > >
> > > Sorry for late reply, I took quite some time to CTS up, comments below.
> > >
> > >> -Original Message-
> > >> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
> > >> Behalf Of Marathe, Yogesh
> > >> Sent: Friday, September 1, 2017 10:16 AM
> > >> To: Tomasz Figa <tf...@chromium.org>
> > >> Cc: Gao, Shuo <shuo@intel.com>; Liu, Zhiquan
> > >> <zhiquan@intel.com>; dani...@collabora.com;
> > >> nicolai.haeh...@amd.com; Antognolli, Rafael
> > >> <rafael.antogno...@intel.com>; e...@engestrom.ch; Emil Velikov
> > >> <emil.l.veli...@gmail.com>; Wu, Zhongmin <zhongmin...@intel.com>;
> > >> kenn...@whitecape.org; Kondapally, Kalyan
> > >> <kalyan.kondapa...@intel.com>; fernetme...@online.de;
> > >> mesa-dev@lists.freedesktop.org; tarc...@itsqueeze.com;
> > >> varad.gau...@collabora.com
> > >> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per
> > >> surface out fence
> > >>
> > >> Tomasz,
> > >>
> > >> > -Original Message-
> > >> > From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
> > >> > Behalf Of Tomasz Figa
> > >> > Sent: Friday, September 1, 2017 9:53 AM
> > >> > To: Marathe, Yogesh <yogesh.mara...@intel.com> On Thu, Aug 31, 2017
> > >> > at 2:18 AM, Marathe, Yogesh <yogesh.mara...@intel.com> wrote:
> > >> > >> -Original Message-
> > >> > >> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org]
> > >> > >> On Behalf Of Emil Velikov
> > >> > >> Sent: Wednesday, August 30, 2017 9:44 PM
> > >> > >> To: Marathe, Yogesh <yogesh.mara...@intel.com>
> > >> > >> Cc: Gao, Shuo <shuo@intel.com>; Liu, Zhiquan
> > >> > >> <zhiquan@intel.com>; dani...@collabora.com;
> > >> > >> nicolai.haeh...@amd.com; Antognolli, Rafael
> > >> > >> <rafael.antogno...@intel.com>; e...@engestrom.ch; Wu, Zhongmin
> > >> > >> <zhongmin...@intel.com>; tf...@chromium.org;
> > >> kenn...@whitecape.org;
> > >> > >> Kondapally, Kalyan <kalyan.kondapa...@intel.com>;
> > >> > >> fernetme...@online.de; mesa-dev@lists.freedesktop.org;
> > >> > >> tarc...@itsqueeze.com; varad.gau...@collabora.com
> > >> > >> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per
> > >> > >> surface out fence
> > >> > >>
> > >> > >> On 30 August 2017 at 15:39, Marathe, Yogesh
> > >> > >> <yogesh.mara...@intel.com>
> > >> > >> wrote:
> > >> > >>
> > >> > >> >
> > >> > >> > Thank you, Tomasz and all involved for the help and guidance.
> > >> > >> >
> > >> > >> Our excitement was short lived - see commit
> > >> > >> 8c9df0daf20206fafb7df77b1edcbc41b8e91372.
> > >> > >>
> > >> > >> Seems the patch was not run through the Intel CI, though I'm
> > >> > >> should not have assumed that you're aware of if.
> > >> > >> Please get in touch with Mark Janes (Cc'd here, janesma on IRC).
>

Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out fence

2017-09-08 Thread Marathe, Yogesh
> -Original Message-
> From: Emil Velikov [mailto:emil.l.veli...@gmail.com]
> Sent: Friday, September 8, 2017 8:28 PM
> To: Marathe, Yogesh <yogesh.mara...@intel.com>
> Cc: Tomasz Figa <tf...@chromium.org>; Antognolli, Rafael
> <rafael.antogno...@intel.com>; Janes, Mark A <mark.a.ja...@intel.com>;
> mesa-dev@lists.freedesktop.org; Gao, Shuo <shuo@intel.com>; Liu,
> Zhiquan <zhiquan@intel.com>; dani...@collabora.com;
> nicolai.haeh...@amd.com; e...@engestrom.ch; Wu, Zhongmin
> <zhongmin...@intel.com>; kenn...@whitecape.org; Kondapally, Kalyan
> <kalyan.kondapa...@intel.com>; fernetme...@online.de;
> tarc...@itsqueeze.com; varad.gau...@collabora.com
> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out
> fence
> 
> On 8 September 2017 at 14:47, Marathe, Yogesh <yogesh.mara...@intel.com>
> wrote:
> > Hello Folks,
> >
> > Sorry for late reply, I took quite some time to CTS up, comments below.
> >
> >> -Original Message-
> >> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
> >> Behalf Of Marathe, Yogesh
> >> Sent: Friday, September 1, 2017 10:16 AM
> >> To: Tomasz Figa <tf...@chromium.org>
> >> Cc: Gao, Shuo <shuo@intel.com>; Liu, Zhiquan
> >> <zhiquan@intel.com>; dani...@collabora.com;
> >> nicolai.haeh...@amd.com; Antognolli, Rafael
> >> <rafael.antogno...@intel.com>; e...@engestrom.ch; Emil Velikov
> >> <emil.l.veli...@gmail.com>; Wu, Zhongmin <zhongmin...@intel.com>;
> >> kenn...@whitecape.org; Kondapally, Kalyan
> >> <kalyan.kondapa...@intel.com>; fernetme...@online.de;
> >> mesa-dev@lists.freedesktop.org; tarc...@itsqueeze.com;
> >> varad.gau...@collabora.com
> >> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per
> >> surface out fence
> >>
> >> Tomasz,
> >>
> >> > -Original Message-
> >> > From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
> >> > Behalf Of Tomasz Figa
> >> > Sent: Friday, September 1, 2017 9:53 AM
> >> > To: Marathe, Yogesh <yogesh.mara...@intel.com> On Thu, Aug 31, 2017
> >> > at 2:18 AM, Marathe, Yogesh <yogesh.mara...@intel.com> wrote:
> >> > >> -Original Message-
> >> > >> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org]
> >> > >> On Behalf Of Emil Velikov
> >> > >> Sent: Wednesday, August 30, 2017 9:44 PM
> >> > >> To: Marathe, Yogesh <yogesh.mara...@intel.com>
> >> > >> Cc: Gao, Shuo <shuo@intel.com>; Liu, Zhiquan
> >> > >> <zhiquan@intel.com>; dani...@collabora.com;
> >> > >> nicolai.haeh...@amd.com; Antognolli, Rafael
> >> > >> <rafael.antogno...@intel.com>; e...@engestrom.ch; Wu, Zhongmin
> >> > >> <zhongmin...@intel.com>; tf...@chromium.org;
> >> kenn...@whitecape.org;
> >> > >> Kondapally, Kalyan <kalyan.kondapa...@intel.com>;
> >> > >> fernetme...@online.de; mesa-dev@lists.freedesktop.org;
> >> > >> tarc...@itsqueeze.com; varad.gau...@collabora.com
> >> > >> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per
> >> > >> surface out fence
> >> > >>
> >> > >> On 30 August 2017 at 15:39, Marathe, Yogesh
> >> > >> <yogesh.mara...@intel.com>
> >> > >> wrote:
> >> > >>
> >> > >> >
> >> > >> > Thank you, Tomasz and all involved for the help and guidance.
> >> > >> >
> >> > >> Our excitement was short lived - see commit
> >> > >> 8c9df0daf20206fafb7df77b1edcbc41b8e91372.
> >> > >>
> >> > >> Seems the patch was not run through the Intel CI, though I'm
> >> > >> should not have assumed that you're aware of if.
> >> > >> Please get in touch with Mark Janes (Cc'd here, janesma on IRC).
> >> > >> He can set you up and/or run a branch for you.
> >> > >>
> >> > >
> >> > > No problem. I will contact Mark.
> >> > >
> >> > > Primarily looks like platform / kernel version issue.
> >> > > intel_get_boolean() for I915_PARAM_HAS_EXEC_FENCE is false, but I
> >> > > see following in i915_drv.c:915_getparam in kernel, no clue why
&

Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out fence

2017-09-08 Thread Emil Velikov
On 8 September 2017 at 14:47, Marathe, Yogesh <yogesh.mara...@intel.com> wrote:
> Hello Folks,
>
> Sorry for late reply, I took quite some time to CTS up, comments below.
>
>> -Original Message-
>> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On Behalf
>> Of Marathe, Yogesh
>> Sent: Friday, September 1, 2017 10:16 AM
>> To: Tomasz Figa <tf...@chromium.org>
>> Cc: Gao, Shuo <shuo@intel.com>; Liu, Zhiquan <zhiquan@intel.com>;
>> dani...@collabora.com; nicolai.haeh...@amd.com; Antognolli, Rafael
>> <rafael.antogno...@intel.com>; e...@engestrom.ch; Emil Velikov
>> <emil.l.veli...@gmail.com>; Wu, Zhongmin <zhongmin...@intel.com>;
>> kenn...@whitecape.org; Kondapally, Kalyan <kalyan.kondapa...@intel.com>;
>> fernetme...@online.de; mesa-dev@lists.freedesktop.org;
>> tarc...@itsqueeze.com; varad.gau...@collabora.com
>> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out
>> fence
>>
>> Tomasz,
>>
>> > -Original Message-
>> > From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
>> > Behalf Of Tomasz Figa
>> > Sent: Friday, September 1, 2017 9:53 AM
>> > To: Marathe, Yogesh <yogesh.mara...@intel.com>
>> > On Thu, Aug 31, 2017 at 2:18 AM, Marathe, Yogesh
>> > <yogesh.mara...@intel.com> wrote:
>> > >> -Original Message-
>> > >> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
>> > >> Behalf Of Emil Velikov
>> > >> Sent: Wednesday, August 30, 2017 9:44 PM
>> > >> To: Marathe, Yogesh <yogesh.mara...@intel.com>
>> > >> Cc: Gao, Shuo <shuo@intel.com>; Liu, Zhiquan
>> > >> <zhiquan@intel.com>; dani...@collabora.com;
>> > >> nicolai.haeh...@amd.com; Antognolli, Rafael
>> > >> <rafael.antogno...@intel.com>; e...@engestrom.ch; Wu, Zhongmin
>> > >> <zhongmin...@intel.com>; tf...@chromium.org;
>> kenn...@whitecape.org;
>> > >> Kondapally, Kalyan <kalyan.kondapa...@intel.com>;
>> > >> fernetme...@online.de; mesa-dev@lists.freedesktop.org;
>> > >> tarc...@itsqueeze.com; varad.gau...@collabora.com
>> > >> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per
>> > >> surface out fence
>> > >>
>> > >> On 30 August 2017 at 15:39, Marathe, Yogesh
>> > >> <yogesh.mara...@intel.com>
>> > >> wrote:
>> > >>
>> > >> >
>> > >> > Thank you, Tomasz and all involved for the help and guidance.
>> > >> >
>> > >> Our excitement was short lived - see commit
>> > >> 8c9df0daf20206fafb7df77b1edcbc41b8e91372.
>> > >>
>> > >> Seems the patch was not run through the Intel CI, though I'm should
>> > >> not have assumed that you're aware of if.
>> > >> Please get in touch with Mark Janes (Cc'd here, janesma on IRC). He
>> > >> can set you up and/or run a branch for you.
>> > >>
>> > >
>> > > No problem. I will contact Mark.
>> > >
>> > > Primarily looks like platform / kernel version issue.
>> > > intel_get_boolean() for I915_PARAM_HAS_EXEC_FENCE is false, but I
>> > > see following in i915_drv.c:915_getparam in kernel, no clue why that
>> > > would come false in UMD.
>> > >
>> > > ...
>> > > case I915_PARAM_HAS_EXEC_FENCE:
>> > > /* For the time being all of these are always true;
>> > >  * if some supported hardware does not have one of these
>> > >  * features this value needs to be provided from
>> > >  * INTEL_INFO(), a feature macro, or similar.
>> > >  */
>> > > value = 1;
>> > > break;
>> > > ...
>> >
>> > Which kernel are you looking at? Remember that not everyone uses
>> > current upstream master. There is a number of upstream stable releases
>> > and downstream forks. Grepping for I915_PARAM_HAS_EXEC_FENCE on
>> > http://elixir.free-electrons.com, shows that it was only added in Linux 
>> > 4.12.
>> >
>>
>> I'm on 4.9.x but I see my kernel  tree has following patch, so this looks 
>> like it is
>> done for android (cherry picked / backport). That’s why i

Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out fence

2017-09-08 Thread Marathe, Yogesh
Hello Folks,

Sorry for late reply, I took quite some time to CTS up, comments below.

> -Original Message-
> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On Behalf
> Of Marathe, Yogesh
> Sent: Friday, September 1, 2017 10:16 AM
> To: Tomasz Figa <tf...@chromium.org>
> Cc: Gao, Shuo <shuo@intel.com>; Liu, Zhiquan <zhiquan@intel.com>;
> dani...@collabora.com; nicolai.haeh...@amd.com; Antognolli, Rafael
> <rafael.antogno...@intel.com>; e...@engestrom.ch; Emil Velikov
> <emil.l.veli...@gmail.com>; Wu, Zhongmin <zhongmin...@intel.com>;
> kenn...@whitecape.org; Kondapally, Kalyan <kalyan.kondapa...@intel.com>;
> fernetme...@online.de; mesa-dev@lists.freedesktop.org;
> tarc...@itsqueeze.com; varad.gau...@collabora.com
> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out
> fence
> 
> Tomasz,
> 
> > -Original Message-
> > From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
> > Behalf Of Tomasz Figa
> > Sent: Friday, September 1, 2017 9:53 AM
> > To: Marathe, Yogesh <yogesh.mara...@intel.com>
> > On Thu, Aug 31, 2017 at 2:18 AM, Marathe, Yogesh
> > <yogesh.mara...@intel.com> wrote:
> > >> -Original Message-
> > >> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
> > >> Behalf Of Emil Velikov
> > >> Sent: Wednesday, August 30, 2017 9:44 PM
> > >> To: Marathe, Yogesh <yogesh.mara...@intel.com>
> > >> Cc: Gao, Shuo <shuo@intel.com>; Liu, Zhiquan
> > >> <zhiquan@intel.com>; dani...@collabora.com;
> > >> nicolai.haeh...@amd.com; Antognolli, Rafael
> > >> <rafael.antogno...@intel.com>; e...@engestrom.ch; Wu, Zhongmin
> > >> <zhongmin...@intel.com>; tf...@chromium.org;
> kenn...@whitecape.org;
> > >> Kondapally, Kalyan <kalyan.kondapa...@intel.com>;
> > >> fernetme...@online.de; mesa-dev@lists.freedesktop.org;
> > >> tarc...@itsqueeze.com; varad.gau...@collabora.com
> > >> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per
> > >> surface out fence
> > >>
> > >> On 30 August 2017 at 15:39, Marathe, Yogesh
> > >> <yogesh.mara...@intel.com>
> > >> wrote:
> > >>
> > >> >
> > >> > Thank you, Tomasz and all involved for the help and guidance.
> > >> >
> > >> Our excitement was short lived - see commit
> > >> 8c9df0daf20206fafb7df77b1edcbc41b8e91372.
> > >>
> > >> Seems the patch was not run through the Intel CI, though I'm should
> > >> not have assumed that you're aware of if.
> > >> Please get in touch with Mark Janes (Cc'd here, janesma on IRC). He
> > >> can set you up and/or run a branch for you.
> > >>
> > >
> > > No problem. I will contact Mark.
> > >
> > > Primarily looks like platform / kernel version issue.
> > > intel_get_boolean() for I915_PARAM_HAS_EXEC_FENCE is false, but I
> > > see following in i915_drv.c:915_getparam in kernel, no clue why that
> > > would come false in UMD.
> > >
> > > ...
> > > case I915_PARAM_HAS_EXEC_FENCE:
> > > /* For the time being all of these are always true;
> > >  * if some supported hardware does not have one of these
> > >  * features this value needs to be provided from
> > >  * INTEL_INFO(), a feature macro, or similar.
> > >  */
> > > value = 1;
> > > break;
> > > ...
> >
> > Which kernel are you looking at? Remember that not everyone uses
> > current upstream master. There is a number of upstream stable releases
> > and downstream forks. Grepping for I915_PARAM_HAS_EXEC_FENCE on
> > http://elixir.free-electrons.com, shows that it was only added in Linux 
> > 4.12.
> >
> 
> I'm on 4.9.x but I see my kernel  tree has following patch, so this looks 
> like it is
> done for android (cherry picked / backport). That’s why it worked for me 
> always!
> 
> commit f0683754f03fa308a2657cb1dadbf235c9607188
> Author: Chris Wilson <ch...@chris-wilson.co.uk>
> Date:   Fri Jan 27 09:40:08 2017 +
> 
> drm/i915: Support explicit fencing for execbuf
> 
> Nonetheless, as you mentioned, I've synced up with Mark and we've created a
> separate branch where CTS / intel mesa CI can run. Let me try to fix this.
> 
> Caveat: To h

Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out fence

2017-08-31 Thread Marathe, Yogesh
Tomasz,

> -Original Message-
> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On Behalf
> Of Tomasz Figa
> Sent: Friday, September 1, 2017 9:53 AM
> To: Marathe, Yogesh <yogesh.mara...@intel.com>
> Cc: Gao, Shuo <shuo@intel.com>; Liu, Zhiquan <zhiquan@intel.com>;
> dani...@collabora.com; nicolai.haeh...@amd.com; Antognolli, Rafael
> <rafael.antogno...@intel.com>; e...@engestrom.ch; Emil Velikov
> <emil.l.veli...@gmail.com>; Wu, Zhongmin <zhongmin...@intel.com>;
> kenn...@whitecape.org; mesa-dev@lists.freedesktop.org;
> fernetme...@online.de; Kondapally, Kalyan <kalyan.kondapa...@intel.com>;
> tarc...@itsqueeze.com; varad.gau...@collabora.com
> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out
> fence
> 
> On Thu, Aug 31, 2017 at 2:18 AM, Marathe, Yogesh
> <yogesh.mara...@intel.com> wrote:
> >> -Original Message-
> >> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
> >> Behalf Of Emil Velikov
> >> Sent: Wednesday, August 30, 2017 9:44 PM
> >> To: Marathe, Yogesh <yogesh.mara...@intel.com>
> >> Cc: Gao, Shuo <shuo@intel.com>; Liu, Zhiquan
> >> <zhiquan@intel.com>; dani...@collabora.com;
> >> nicolai.haeh...@amd.com; Antognolli, Rafael
> >> <rafael.antogno...@intel.com>; e...@engestrom.ch; Wu, Zhongmin
> >> <zhongmin...@intel.com>; tf...@chromium.org; kenn...@whitecape.org;
> >> Kondapally, Kalyan <kalyan.kondapa...@intel.com>;
> >> fernetme...@online.de; mesa-dev@lists.freedesktop.org;
> >> tarc...@itsqueeze.com; varad.gau...@collabora.com
> >> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per
> >> surface out fence
> >>
> >> On 30 August 2017 at 15:39, Marathe, Yogesh
> >> <yogesh.mara...@intel.com>
> >> wrote:
> >>
> >> >
> >> > Thank you, Tomasz and all involved for the help and guidance.
> >> >
> >> Our excitement was short lived - see commit
> >> 8c9df0daf20206fafb7df77b1edcbc41b8e91372.
> >>
> >> Seems the patch was not run through the Intel CI, though I'm should
> >> not have assumed that you're aware of if.
> >> Please get in touch with Mark Janes (Cc'd here, janesma on IRC). He
> >> can set you up and/or run a branch for you.
> >>
> >
> > No problem. I will contact Mark.
> >
> > Primarily looks like platform / kernel version issue.
> > intel_get_boolean() for I915_PARAM_HAS_EXEC_FENCE is false, but I see
> > following in i915_drv.c:915_getparam in kernel, no clue why that would
> > come false in UMD.
> >
> > ...
> > case I915_PARAM_HAS_EXEC_FENCE:
> > /* For the time being all of these are always true;
> >  * if some supported hardware does not have one of these
> >  * features this value needs to be provided from
> >  * INTEL_INFO(), a feature macro, or similar.
> >  */
> > value = 1;
> > break;
> > ...
> 
> Which kernel are you looking at? Remember that not everyone uses current
> upstream master. There is a number of upstream stable releases and
> downstream forks. Grepping for I915_PARAM_HAS_EXEC_FENCE on
> http://elixir.free-electrons.com, shows that it was only added in Linux 4.12.
> 

I'm on 4.9.x but I see my kernel  tree has following patch, so this looks like 
it is
done for android (cherry picked / backport). That’s why it worked for me always!

commit f0683754f03fa308a2657cb1dadbf235c9607188
Author: Chris Wilson <ch...@chris-wilson.co.uk>
Date:   Fri Jan 27 09:40:08 2017 +

drm/i915: Support explicit fencing for execbuf

Nonetheless, as you mentioned, I've synced up with Mark and we've created a 
separate branch where CTS / intel mesa CI can run. Let me try to fix this.

Caveat: To have flatland running on android  there was another issue in kernel 
which
needed a fix. Details - https://bugs.freedesktop.org/show_bug.cgi?id=101656

> Best regards,
> Tomasz
> ___
> 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 v6.2] egl: Allow creation of per surface out fence

2017-08-31 Thread Tomasz Figa
On Thu, Aug 31, 2017 at 2:18 AM, Marathe, Yogesh
<yogesh.mara...@intel.com> wrote:
>> -Original Message-
>> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On Behalf
>> Of Emil Velikov
>> Sent: Wednesday, August 30, 2017 9:44 PM
>> To: Marathe, Yogesh <yogesh.mara...@intel.com>
>> Cc: Gao, Shuo <shuo@intel.com>; Liu, Zhiquan <zhiquan@intel.com>;
>> dani...@collabora.com; nicolai.haeh...@amd.com; Antognolli, Rafael
>> <rafael.antogno...@intel.com>; e...@engestrom.ch; Wu, Zhongmin
>> <zhongmin...@intel.com>; tf...@chromium.org; kenn...@whitecape.org;
>> Kondapally, Kalyan <kalyan.kondapa...@intel.com>; fernetme...@online.de;
>> mesa-dev@lists.freedesktop.org; tarc...@itsqueeze.com;
>> varad.gau...@collabora.com
>> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out
>> fence
>>
>> On 30 August 2017 at 15:39, Marathe, Yogesh <yogesh.mara...@intel.com>
>> wrote:
>>
>> >
>> > Thank you, Tomasz and all involved for the help and guidance.
>> >
>> Our excitement was short lived - see commit
>> 8c9df0daf20206fafb7df77b1edcbc41b8e91372.
>>
>> Seems the patch was not run through the Intel CI, though I'm should not have
>> assumed that you're aware of if.
>> Please get in touch with Mark Janes (Cc'd here, janesma on IRC). He can set 
>> you
>> up and/or run a branch for you.
>>
>
> No problem. I will contact Mark.
>
> Primarily looks like platform / kernel version issue. intel_get_boolean() for
> I915_PARAM_HAS_EXEC_FENCE is false, but I see following in
> i915_drv.c:915_getparam in kernel, no clue why that would come false
> in UMD.
>
> ...
> case I915_PARAM_HAS_EXEC_FENCE:
> /* For the time being all of these are always true;
>  * if some supported hardware does not have one of these
>  * features this value needs to be provided from
>  * INTEL_INFO(), a feature macro, or similar.
>  */
> value = 1;
> break;
> ...

Which kernel are you looking at? Remember that not everyone uses
current upstream master. There is a number of upstream stable releases
and downstream forks. Grepping for I915_PARAM_HAS_EXEC_FENCE on
http://elixir.free-electrons.com, shows that it was only added in
Linux 4.12.

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


Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out fence

2017-08-30 Thread Marathe, Yogesh
> -Original Message-
> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On Behalf
> Of Emil Velikov
> Sent: Wednesday, August 30, 2017 9:44 PM
> To: Marathe, Yogesh <yogesh.mara...@intel.com>
> Cc: Gao, Shuo <shuo@intel.com>; Liu, Zhiquan <zhiquan@intel.com>;
> dani...@collabora.com; nicolai.haeh...@amd.com; Antognolli, Rafael
> <rafael.antogno...@intel.com>; e...@engestrom.ch; Wu, Zhongmin
> <zhongmin...@intel.com>; tf...@chromium.org; kenn...@whitecape.org;
> Kondapally, Kalyan <kalyan.kondapa...@intel.com>; fernetme...@online.de;
> mesa-dev@lists.freedesktop.org; tarc...@itsqueeze.com;
> varad.gau...@collabora.com
> Subject: Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out
> fence
> 
> On 30 August 2017 at 15:39, Marathe, Yogesh <yogesh.mara...@intel.com>
> wrote:
> 
> >
> > Thank you, Tomasz and all involved for the help and guidance.
> >
> Our excitement was short lived - see commit
> 8c9df0daf20206fafb7df77b1edcbc41b8e91372.
> 
> Seems the patch was not run through the Intel CI, though I'm should not have
> assumed that you're aware of if.
> Please get in touch with Mark Janes (Cc'd here, janesma on IRC). He can set 
> you
> up and/or run a branch for you.
> 

No problem. I will contact Mark. 

Primarily looks like platform / kernel version issue. intel_get_boolean() for 
I915_PARAM_HAS_EXEC_FENCE is false, but I see following in
i915_drv.c:915_getparam in kernel, no clue why that would come false
in UMD.

...
case I915_PARAM_HAS_EXEC_FENCE:
/* For the time being all of these are always true;
 * if some supported hardware does not have one of these
 * features this value needs to be provided from
 * INTEL_INFO(), a feature macro, or similar.
 */
value = 1;
break;
...

> Thanks
> Emil
> ___
> 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 v6.2] egl: Allow creation of per surface out fence

2017-08-30 Thread Emil Velikov
On 30 August 2017 at 15:39, Marathe, Yogesh  wrote:

>
> Thank you, Tomasz and all involved for the help and guidance.
>
Our excitement was short lived - see commit
8c9df0daf20206fafb7df77b1edcbc41b8e91372.

Seems the patch was not run through the Intel CI, though I'm should
not have assumed that you're aware of if.
Please get in touch with Mark Janes (Cc'd here, janesma on IRC). He
can set you up and/or run a branch for you.

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


Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out fence

2017-08-30 Thread Marathe, Yogesh
> -Original Message-
> From: Emil Velikov [mailto:emil.l.veli...@gmail.com]
> Sent: Wednesday, August 30, 2017 4:39 PM
> To: Marathe, Yogesh 
> Cc: mesa-dev@lists.freedesktop.org; tf...@chromium.org; Gao, Shuo
> ; Liu, Zhiquan ;
> dani...@collabora.com; nicolai.haeh...@amd.com; Antognolli, Rafael
> ; e...@engestrom.ch; kenn...@whitecape.org;
> fernetme...@online.de; Kondapally, Kalyan ;
> tarc...@itsqueeze.com; varad.gau...@collabora.com; Wu, Zhongmin
> 
> Subject: Re: [PATCH v6.2] egl: Allow creation of per surface out fence
> 
> On 28 August 2017 at 11:27, Marathe, Yogesh 
> wrote:
> > This still doesn't seem to be merged. Can someone please look at it? It does
> have Rbs.
> >
> Done. Thanks for the work and patience on getting this sorted.

You're welcome. 

Thank you, Tomasz and all involved for the help and guidance.

Regards,
Yogesh.

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


Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out fence

2017-08-30 Thread Emil Velikov
On 28 August 2017 at 11:27, Marathe, Yogesh  wrote:
> This still doesn't seem to be merged. Can someone please look at it? It does 
> have Rbs.
>
Done. Thanks for the work and patience on getting this sorted.

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


Re: [Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out fence

2017-08-28 Thread Marathe, Yogesh
This still doesn't seem to be merged. Can someone please look at it? It does 
have Rbs.

Regards,
Yogesh.

> -Original Message-
> From: Marathe, Yogesh
> Sent: Wednesday, August 23, 2017 11:35 PM
> To: mesa-dev@lists.freedesktop.org
> Cc: tf...@chromium.org; emil.l.veli...@gmail.com; Gao, Shuo
> ; Liu, Zhiquan ;
> dani...@collabora.com; nicolai.haeh...@amd.com; Antognolli, Rafael
> ; e...@engestrom.ch; kenn...@whitecape.org;
> fernetme...@online.de; Kondapally, Kalyan ;
> tarc...@itsqueeze.com; varad.gau...@collabora.com; Wu, Zhongmin
> ; Marathe, Yogesh 
> Subject: [PATCH v6.2] egl: Allow creation of per surface out fence
> 
> From: Zhongmin Wu 
> 
> Add plumbing to allow creation of per display surface out fence.
> 
> Currently enabled only on android, since the system expects a valid fd in
> ANativeWindow::{queue,cancel}Buffer. We pass a fd of -1 with which native
> applications such as flatland fail. The patch enables explicit sync on 
> android and
> fixes one of the functional issue for apps or buffer consumers which depend
> upon fence and its timestamp.
> 
> v2: a) Also implement the fence in cancelBuffer.
> b) The last sync fence is stored in drawable object
>rather than brw context.
> c) format clear.
> 
> v3: a) Save the last fence fd in DRI Context object.
> b) Return the last fence if the batch buffer is empty and
>nothing to be flushed when _intel_batchbuffer_flush_fence
> c) Add the new interface in vbtl to set the retrieve fence
> 
> v3.1 a) close fd in the new vbtl interface on none Android platform
> 
> v4: a) The last fence is saved in brw context.
> b) The retrieve fd is for all the platform but not just Android
> c) Add a uniform dri2 interface to initialize the surface.
> 
> v4.1: a) make some changes of variable name.
>   b) the patch is broken into two patches.
> 
> v4.2: a) Add a deinit interface for surface to clear the out fence
> 
> v5: a) Add enable_out_fence to init, platform sets it true or
>false
> b) Change get fd to update fd and check for fence
> c) Commit description updated
> 
> v6: a) Heading and commit description updated
> b) enable_out_fence is set only if fence is supported
> c) Review comments on function names
> d) Test with standalone patch, resolves the bug
> 
> v6.1: Check for old display fence reverted
> 
> v6.2: enable_out_fence initialized to false by default,
>   dri2_surf_update_fence_fd updated, deinit changed to fini
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101655
> 
> Signed-off-by: Zhongmin Wu 
> Signed-off-by: Yogesh Marathe 
> Reviewed-by: Emil Velikov 
> Reviewed-by: Tomasz Figa 
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 71 
> +
>  src/egl/drivers/dri2/egl_dri2.h |  9 
>  src/egl/drivers/dri2/platform_android.c | 29 ++--
>  src/egl/drivers/dri2/platform_drm.c |  3 +-
>  src/egl/drivers/dri2/platform_surfaceless.c |  3 +-
>  src/egl/drivers/dri2/platform_wayland.c |  3 +-
>  src/egl/drivers/dri2/platform_x11.c |  3 +-
>  src/egl/drivers/dri2/platform_x11_dri3.c|  3 +-
>  8 files changed, 106 insertions(+), 18 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c 
> b/src/egl/drivers/dri2/egl_dri2.c index
> aa6f02a..44b8e1d 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -1388,6 +1388,45 @@ dri2_destroy_context(_EGLDriver *drv, _EGLDisplay
> *disp, _EGLContext *ctx)
> return EGL_TRUE;
>  }
> 
> +EGLBoolean
> +dri2_init_surface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
> +_EGLConfig *conf, const EGLint *attrib_list, EGLBoolean
> +enable_out_fence) {
> +   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
> +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
> +
> +   dri2_surf->out_fence_fd = -1;
> +   dri2_surf->enable_out_fence = false;
> +   if (dri2_dpy->fence && dri2_dpy->fence->base.version >= 2 &&
> +   dri2_dpy->fence->get_capabilities &&
> +   (dri2_dpy->fence->get_capabilities(dri2_dpy->dri_screen) &
> +__DRI_FENCE_CAP_NATIVE_FD)) {
> +  dri2_surf->enable_out_fence = enable_out_fence;
> +   }
> +
> +   return _eglInitSurface(surf, dpy, type, conf, attrib_list); }
> +
> +static void
> +dri2_surface_set_out_fence_fd( _EGLSurface *surf, int fence_fd) {
> +   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
> +
> +   if (dri2_surf->out_fence_fd >=0)
> +  close(dri2_surf->out_fence_fd);
> +
> +   dri2_surf->out_fence_fd = fence_fd;
> +}
> +
> +void
> +dri2_fini_surface(_EGLSurface *surf)
> +{
> +   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
> 

[Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out fence

2017-08-23 Thread yogesh . marathe
From: Zhongmin Wu 

Add plumbing to allow creation of per display surface out fence.

Currently enabled only on android, since the system expects a valid
fd in ANativeWindow::{queue,cancel}Buffer. We pass a fd of -1 with
which native applications such as flatland fail. The patch enables
explicit sync on android and fixes one of the functional issue for
apps or buffer consumers which depend upon fence and its timestamp.

v2: a) Also implement the fence in cancelBuffer.
b) The last sync fence is stored in drawable object
   rather than brw context.
c) format clear.

v3: a) Save the last fence fd in DRI Context object.
b) Return the last fence if the batch buffer is empty and
   nothing to be flushed when _intel_batchbuffer_flush_fence
c) Add the new interface in vbtl to set the retrieve fence

v3.1 a) close fd in the new vbtl interface on none Android platform

v4: a) The last fence is saved in brw context.
b) The retrieve fd is for all the platform but not just Android
c) Add a uniform dri2 interface to initialize the surface.

v4.1: a) make some changes of variable name.
  b) the patch is broken into two patches.

v4.2: a) Add a deinit interface for surface to clear the out fence

v5: a) Add enable_out_fence to init, platform sets it true or
   false
b) Change get fd to update fd and check for fence
c) Commit description updated

v6: a) Heading and commit description updated
b) enable_out_fence is set only if fence is supported
c) Review comments on function names
d) Test with standalone patch, resolves the bug

v6.1: Check for old display fence reverted

v6.2: enable_out_fence initialized to false by default,
  dri2_surf_update_fence_fd updated, deinit changed to fini

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101655

Signed-off-by: Zhongmin Wu 
Signed-off-by: Yogesh Marathe 
Reviewed-by: Emil Velikov 
Reviewed-by: Tomasz Figa 
---
 src/egl/drivers/dri2/egl_dri2.c | 71 +
 src/egl/drivers/dri2/egl_dri2.h |  9 
 src/egl/drivers/dri2/platform_android.c | 29 ++--
 src/egl/drivers/dri2/platform_drm.c |  3 +-
 src/egl/drivers/dri2/platform_surfaceless.c |  3 +-
 src/egl/drivers/dri2/platform_wayland.c |  3 +-
 src/egl/drivers/dri2/platform_x11.c |  3 +-
 src/egl/drivers/dri2/platform_x11_dri3.c|  3 +-
 8 files changed, 106 insertions(+), 18 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index aa6f02a..44b8e1d 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1388,6 +1388,45 @@ dri2_destroy_context(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLContext *ctx)
return EGL_TRUE;
 }
 
+EGLBoolean
+dri2_init_surface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
+_EGLConfig *conf, const EGLint *attrib_list, EGLBoolean 
enable_out_fence)
+{
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+
+   dri2_surf->out_fence_fd = -1;
+   dri2_surf->enable_out_fence = false;
+   if (dri2_dpy->fence && dri2_dpy->fence->base.version >= 2 &&
+   dri2_dpy->fence->get_capabilities &&
+   (dri2_dpy->fence->get_capabilities(dri2_dpy->dri_screen) &
+__DRI_FENCE_CAP_NATIVE_FD)) {
+  dri2_surf->enable_out_fence = enable_out_fence;
+   }
+
+   return _eglInitSurface(surf, dpy, type, conf, attrib_list);
+}
+
+static void
+dri2_surface_set_out_fence_fd( _EGLSurface *surf, int fence_fd)
+{
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+
+   if (dri2_surf->out_fence_fd >=0)
+  close(dri2_surf->out_fence_fd);
+
+   dri2_surf->out_fence_fd = fence_fd;
+}
+
+void
+dri2_fini_surface(_EGLSurface *surf)
+{
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+
+   dri2_surface_set_out_fence_fd(surf, -1);
+   dri2_surf->enable_out_fence = false;
+}
+
 static EGLBoolean
 dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
 {
@@ -1399,6 +1438,28 @@ dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, 
_EGLSurface *surf)
return dri2_dpy->vtbl->destroy_surface(drv, dpy, surf);
 }
 
+static void
+dri2_surf_update_fence_fd(_EGLContext *ctx,
+  _EGLDisplay *dpy, _EGLSurface *surf)
+{
+   __DRIcontext *dri_ctx = dri2_egl_context(ctx)->dri_context;
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+   int fence_fd = -1;
+   void *fence;
+
+   if (!dri2_surf->enable_out_fence)
+  return;
+
+   fence = dri2_dpy->fence->create_fence_fd(dri_ctx, -1);
+   if (fence) {
+  fence_fd = dri2_dpy->fence->get_fence_fd(dri2_dpy->dri_screen,
+   fence);
+  

[Mesa-dev] [PATCH v6.2] egl: Allow creation of per surface out fence

2017-08-23 Thread yogesh . marathe
From: Zhongmin Wu 

Add plumbing to allow creation of per display surface out fence.

Currently enabled only on android, since the system expects a valid
fd in ANativeWindow::{queue,cancel}Buffer. We pass a fd of -1 with
which native applications such as flatland fail. The patch enables
explicit sync on android and fixes one of the functional issue for
apps or buffer consumers which depend upon fence and its timestamp.

v2: a) Also implement the fence in cancelBuffer.
b) The last sync fence is stored in drawable object
   rather than brw context.
c) format clear.

v3: a) Save the last fence fd in DRI Context object.
b) Return the last fence if the batch buffer is empty and
   nothing to be flushed when _intel_batchbuffer_flush_fence
c) Add the new interface in vbtl to set the retrieve fence

v3.1 a) close fd in the new vbtl interface on none Android platform

v4: a) The last fence is saved in brw context.
b) The retrieve fd is for all the platform but not just Android
c) Add a uniform dri2 interface to initialize the surface.

v4.1: a) make some changes of variable name.
  b) the patch is broken into two patches.

v4.2: a) Add a deinit interface for surface to clear the out fence

v5: a) Add enable_out_fence to init, platform sets it true or
   false
b) Change get fd to update fd and check for fence
c) Commit description updated

v6: a) Heading and commit description updated
b) enable_out_fence is set only if fence is supported
c) Review comments on function names
d) Test with standalone patch, resolves the bug

v6.2: a) Check for old display fence reverted
  b) enable_out_fence initialized to false by default,
 dri2_surf_update_fence_fd updated, deinit changed to fini

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101655

Signed-off-by: Zhongmin Wu 
Signed-off-by: Yogesh Marathe 
Reviewed-by: Emil Velikov 
Reviewed-by: Tomasz Figa 
---
 src/egl/drivers/dri2/egl_dri2.c | 71 +
 src/egl/drivers/dri2/egl_dri2.h |  9 
 src/egl/drivers/dri2/platform_android.c | 29 ++--
 src/egl/drivers/dri2/platform_drm.c |  3 +-
 src/egl/drivers/dri2/platform_surfaceless.c |  3 +-
 src/egl/drivers/dri2/platform_wayland.c |  3 +-
 src/egl/drivers/dri2/platform_x11.c |  3 +-
 src/egl/drivers/dri2/platform_x11_dri3.c|  3 +-
 8 files changed, 106 insertions(+), 18 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index aa6f02a..44b8e1d 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1388,6 +1388,45 @@ dri2_destroy_context(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLContext *ctx)
return EGL_TRUE;
 }
 
+EGLBoolean
+dri2_init_surface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
+_EGLConfig *conf, const EGLint *attrib_list, EGLBoolean 
enable_out_fence)
+{
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+
+   dri2_surf->out_fence_fd = -1;
+   dri2_surf->enable_out_fence = false;
+   if (dri2_dpy->fence && dri2_dpy->fence->base.version >= 2 &&
+   dri2_dpy->fence->get_capabilities &&
+   (dri2_dpy->fence->get_capabilities(dri2_dpy->dri_screen) &
+__DRI_FENCE_CAP_NATIVE_FD)) {
+  dri2_surf->enable_out_fence = enable_out_fence;
+   }
+
+   return _eglInitSurface(surf, dpy, type, conf, attrib_list);
+}
+
+static void
+dri2_surface_set_out_fence_fd( _EGLSurface *surf, int fence_fd)
+{
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+
+   if (dri2_surf->out_fence_fd >=0)
+  close(dri2_surf->out_fence_fd);
+
+   dri2_surf->out_fence_fd = fence_fd;
+}
+
+void
+dri2_fini_surface(_EGLSurface *surf)
+{
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+
+   dri2_surface_set_out_fence_fd(surf, -1);
+   dri2_surf->enable_out_fence = false;
+}
+
 static EGLBoolean
 dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
 {
@@ -1399,6 +1438,28 @@ dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, 
_EGLSurface *surf)
return dri2_dpy->vtbl->destroy_surface(drv, dpy, surf);
 }
 
+static void
+dri2_surf_update_fence_fd(_EGLContext *ctx,
+  _EGLDisplay *dpy, _EGLSurface *surf)
+{
+   __DRIcontext *dri_ctx = dri2_egl_context(ctx)->dri_context;
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+   int fence_fd = -1;
+   void *fence;
+
+   if (!dri2_surf->enable_out_fence)
+  return;
+
+   fence = dri2_dpy->fence->create_fence_fd(dri_ctx, -1);
+   if (fence) {
+  fence_fd = dri2_dpy->fence->get_fence_fd(dri2_dpy->dri_screen,
+   fence);
+