Re: [Mesa-dev] [PATCH 2/2] loader_dri3: Variant 2: Wait for pending swaps to complete before drawable_fini.

2018-05-04 Thread Mike Lothian
Hi

The first hunk doesn't apply, the other 3 gives this with GCC 8.1


../mesa-/src/loader/loader_dri3_helper.c: In function
‘dri3_handle_present_event’:
../mesa-/src/loader/loader_dri3_helper.c:376:13: error: implicit
declaration of function ‘printf’
[-Werror=implicit-function-declaration]
 printf("ORPHAN-C: %d x %d, drawable %d: recv %u vs send_sbc %lu\n",
 ^~
../mesa-/src/loader/loader_dri3_helper.c:376:13: warning:
incompatible implicit declaration of built-in function ‘printf’
../mesa-/src/loader/loader_dri3_helper.c:376:13: note: include
‘’ or provide a declaration of ‘printf’
../mesa-/src/loader/loader_dri3_helper.c:39:1:
+#include 

../mesa-/src/loader/loader_dri3_helper.c:376:13:
 printf("ORPHAN-C: %d x %d, drawable %d: recv %u vs send_sbc %lu\n",
 ^~
../mesa-/src/loader/loader_dri3_helper.c:376:75: warning: format
‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has
type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
 printf("ORPHAN-C: %d x %d, drawable %d: recv %u vs send_sbc %lu\n",
 ~~^
 %llu
../mesa-/src/loader/loader_dri3_helper.c:378:20:
draw->send_sbc);
~~
../mesa-/src/loader/loader_dri3_helper.c:430:10: warning:
incompatible implicit declaration of built-in function ‘printf’
  printf("ORPHAN-I: %d x %d, drawable %d: recv %u vs send_sbc %lu\n",
  ^~
../mesa-/src/loader/loader_dri3_helper.c:430:10: note: include
‘’ or provide a declaration of ‘printf’
../mesa-/src/loader/loader_dri3_helper.c:430:72: warning: format
‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has
type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
  printf("ORPHAN-I: %d x %d, drawable %d: recv %u vs send_sbc %lu\n",
  ~~^
  %llu
../mesa-/src/loader/loader_dri3_helper.c:432:17:
 draw->send_sbc);
 ~~
../mesa-/src/loader/loader_dri3_helper.c: In function
‘dri3_update_drawable’:
../mesa-/src/loader/loader_dri3_helper.c:1454:7: warning:
incompatible implicit declaration of built-in function ‘printf’
   printf("INIT: wxh = %d x %d, drawable %d eid %d\n",
draw->width, draw->height, draw->drawable, draw->eid);
   ^~
../mesa-/src/loader/loader_dri3_helper.c:1454:7: note: include
‘’ or provide a declaration of ‘printf’
cc1: some warnings being treated as errors

Cheers

Mike

On 4 May 2018 at 14:45, Mario Kleiner  wrote:
> See previous patch in series for explanation of the problem.
>
> This method avoids a blocking loader_dri3_swapbuffer_barrier() call
> whenever a GL contexts drawables are changed via glXMakeCurrent et al.
>
> Instead it filters out the "orphaned" PresentNotify events from
> previous incarnations of the loader_dri3_drawable. This should deal
> correctly with PixmapInvalidate, PixmapPresentCompleteNotify and
> MscCompleteNotify events, but i don't know a way to filter out
> WindowConfigureNotify events, or if it even matters to filter them.
>
> This PoC one is only meaningful if the first patch is omitted, and
> shows the spurious "ORPHAN" printouts which would hang KDE plasmashell
> if not filtered out.
>
> Test from a terminal: killall plasmashell; plasmashell
> Wiggly the mouse around, click etc. on the KDE taskbar, K-Menu,
> system tray icons, trigger volume/brightness feedback widgets
> to provoke the occassional ORPHAN event.
>
> Signed-off-by: Mario Kleiner 
> Cc: xorg-de...@lists.x.org
> Cc: dan...@fooishbar.org
> Cc: eero.t.tammi...@intel.com
> Cc: m...@fireburn.co.uk
> ---
>  src/loader/loader_dri3_helper.c | 24 
>  1 file changed, 24 insertions(+)
>
> diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
> index 7bd79af..123a996 100644
> --- a/src/loader/loader_dri3_helper.c
> +++ b/src/loader/loader_dri3_helper.c
> @@ -234,6 +234,10 @@ loader_dri3_drawable_fini(struct loader_dri3_drawable 
> *draw)
>  {
> int i;
>
> +   printf("FINI: wxh = %d x %d, drawable %d eid %d recv_sbc %lu, send_sbc 
> %lu PENDING %lu\n",
> +  draw->width, draw->height, draw->drawable, draw->eid, 
> draw->recv_sbc, draw->send_sbc,
> +  draw->send_sbc - draw->recv_sbc);
> +
> if (draw->special_event)
>loader_dri3_swapbuffer_barrier(draw);
>
> @@ -373,6 +377,15 @@ dri3_handle_present_event(struct loader_dri3_drawable 
> *draw,
> * checking for wrap.
> */
>if (ce->kind == XCB_PRESENT_COMPLETE_KIND_PIXMAP) {
> + /* Filter out orphan events sent for a previous incarnation of 
> draw. */
> + if (!(draw->send_sbc & 0x00

Re: [Mesa-dev] [PATCH 2/2] loader_dri3: Variant 2: Wait for pending swaps to complete before drawable_fini.

2018-05-04 Thread Mario Kleiner
On Fri, May 4, 2018 at 6:45 PM, Mike Lothian  wrote:
> Hi
>
> The first hunk doesn't apply, the other 3 gives this with GCC 8.1
>

Oops, the perils of applying debug patches on top of debug patches...

Can you add a...

#include 

at the top of the file, e.g, after '#include 

 #include 
 #include 
 #include 
-
+#include 
 #include 
 #include 
 #include 

Then it should compile, albeit with some format warnings, but those
shouldn't affect the outcome.
-mario

>
> ../mesa-/src/loader/loader_dri3_helper.c: In function
> ‘dri3_handle_present_event’:
> ../mesa-/src/loader/loader_dri3_helper.c:376:13: error: implicit
> declaration of function ‘printf’
> [-Werror=implicit-function-declaration]
>  printf("ORPHAN-C: %d x %d, drawable %d: recv %u vs send_sbc 
> %lu\n",
>  ^~
> ../mesa-/src/loader/loader_dri3_helper.c:376:13: warning:
> incompatible implicit declaration of built-in function ‘printf’
> ../mesa-/src/loader/loader_dri3_helper.c:376:13: note: include
> ‘’ or provide a declaration of ‘printf’
> ../mesa-/src/loader/loader_dri3_helper.c:39:1:
> +#include 
>
> ../mesa-/src/loader/loader_dri3_helper.c:376:13:
>  printf("ORPHAN-C: %d x %d, drawable %d: recv %u vs send_sbc 
> %lu\n",
>  ^~
> ../mesa-/src/loader/loader_dri3_helper.c:376:75: warning: format
> ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has
> type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
>  printf("ORPHAN-C: %d x %d, drawable %d: recv %u vs send_sbc 
> %lu\n",
>  ~~^
>  %llu
> ../mesa-/src/loader/loader_dri3_helper.c:378:20:
> draw->send_sbc);
> ~~
> ../mesa-/src/loader/loader_dri3_helper.c:430:10: warning:
> incompatible implicit declaration of built-in function ‘printf’
>   printf("ORPHAN-I: %d x %d, drawable %d: recv %u vs send_sbc %lu\n",
>   ^~
> ../mesa-/src/loader/loader_dri3_helper.c:430:10: note: include
> ‘’ or provide a declaration of ‘printf’
> ../mesa-/src/loader/loader_dri3_helper.c:430:72: warning: format
> ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has
> type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
>   printf("ORPHAN-I: %d x %d, drawable %d: recv %u vs send_sbc %lu\n",
>   ~~^
>   %llu
> ../mesa-/src/loader/loader_dri3_helper.c:432:17:
>  draw->send_sbc);
>  ~~
> ../mesa-/src/loader/loader_dri3_helper.c: In function
> ‘dri3_update_drawable’:
> ../mesa-/src/loader/loader_dri3_helper.c:1454:7: warning:
> incompatible implicit declaration of built-in function ‘printf’
>printf("INIT: wxh = %d x %d, drawable %d eid %d\n",
> draw->width, draw->height, draw->drawable, draw->eid);
>^~
> ../mesa-/src/loader/loader_dri3_helper.c:1454:7: note: include
> ‘’ or provide a declaration of ‘printf’
> cc1: some warnings being treated as errors
>
> Cheers
>
> Mike
>
> On 4 May 2018 at 14:45, Mario Kleiner  wrote:
>> See previous patch in series for explanation of the problem.
>>
>> This method avoids a blocking loader_dri3_swapbuffer_barrier() call
>> whenever a GL contexts drawables are changed via glXMakeCurrent et al.
>>
>> Instead it filters out the "orphaned" PresentNotify events from
>> previous incarnations of the loader_dri3_drawable. This should deal
>> correctly with PixmapInvalidate, PixmapPresentCompleteNotify and
>> MscCompleteNotify events, but i don't know a way to filter out
>> WindowConfigureNotify events, or if it even matters to filter them.
>>
>> This PoC one is only meaningful if the first patch is omitted, and
>> shows the spurious "ORPHAN" printouts which would hang KDE plasmashell
>> if not filtered out.
>>
>> Test from a terminal: killall plasmashell; plasmashell
>> Wiggly the mouse around, click etc. on the KDE taskbar, K-Menu,
>> system tray icons, trigger volume/brightness feedback widgets
>> to provoke the occassional ORPHAN event.
>>
>> Signed-off-by: Mario Kleiner 
>> Cc: xorg-de...@lists.x.org
>> Cc: dan...@fooishbar.org
>> Cc: eero.t.tammi...@intel.com
>> Cc: m...@fireburn.co.uk
>> ---
>>  src/loader/loader_dri3_helper.c | 24 
>>  1 file changed, 24 insertions(+)
>>
>> diff --git a/src/loader/loader_dri3_helper.c 
>> b/src/loader/loader_dri3_helper.c
>> index 7bd79af..123a996 100644
>> --- a/src/loader/loader_dri3_helper.c
>> +++ b/src/loader/loader_dri3_helper.c
>> @@ -234,6 +234,10 @@ loader_dri3_drawable_fini(struct loader_dri3_drawable 
>> *draw)
>>  {
>> int i;
>>
>> +   printf("FINI: wxh = %d x %d, drawable %d eid %d recv_sbc %lu, send_sbc 
>> %lu PENDING %lu\n",
>> +  

Re: [Mesa-dev] [PATCH 2/2] loader_dri3: Variant 2: Wait for pending swaps to complete before drawable_fini.

2018-05-04 Thread Mike Lothian
 src/loader/loader_dri3_helper.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index 23729f7ecb..2b2a8d21d8 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -26,6 +26,7 @@
 #include 
 #include 

+#include 
 #include 
 #include 
 #include 
@@ -234,6 +235,10 @@ loader_dri3_drawable_fini(struct
loader_dri3_drawable *draw)
 {
int i;

+   printf("FINI: wxh = %d x %d, drawable %d eid %d recv_sbc %lu,
send_sbc %lu PENDING %lu\n",
+  draw->width, draw->height, draw->drawable, draw->eid,
draw->recv_sbc, draw->send_sbc,
+  draw->send_sbc - draw->recv_sbc);
+
draw->ext->core->destroyDrawable(draw->dri_drawable);

for (i = 0; i < ARRAY_SIZE(draw->buffers); i++) {
@@ -370,6 +375,15 @@ dri3_handle_present_event(struct
loader_dri3_drawable *draw,
* checking for wrap.
*/
   if (ce->kind == XCB_PRESENT_COMPLETE_KIND_PIXMAP) {
+ /* Filter out orphan events sent for a previous incarnation
of draw. */
+ if (!(draw->send_sbc & 0xLL) &&
+ ce->serial > draw->send_sbc) {
+printf("ORPHAN-C: %d x %d, drawable %d: recv %u vs send_sbc %lu\n",
+   draw->width, draw->height, draw->drawable, ce->serial,
+   draw->send_sbc);
+break;
+ }
+
  draw->recv_sbc = (draw->send_sbc & 0xLL) | ce->serial;
  if (draw->recv_sbc > draw->send_sbc)
 draw->recv_sbc -= 0x1;
@@ -415,6 +429,15 @@ dri3_handle_present_event(struct
loader_dri3_drawable *draw,
   xcb_present_idle_notify_event_t *ie = (void *) ge;
   int b;

+  /* Filter out orphan events sent for a previous incarnation of draw. */
+  if (!(draw->send_sbc & 0xLL) &&
+  ie->serial > draw->send_sbc) {
+ printf("ORPHAN-I: %d x %d, drawable %d: recv %u vs send_sbc %lu\n",
+draw->width, draw->height, draw->drawable, ie->serial,
+draw->send_sbc);
+ break;
+  }
+
   for (b = 0; b < ARRAY_SIZE(draw->buffers); b++) {
  struct loader_dri3_buffer *buf = draw->buffers[b];

@@ -1432,6 +1455,8 @@ dri3_update_drawable(__DRIdrawable *driDrawable,
  xcb_unregister_for_special_event(draw->conn, draw->special_event);
  draw->special_event = NULL;
   }
+
+  printf("INIT: wxh = %d x %d, drawable %d eid %d\n",
draw->width, draw->height, draw->drawable, draw->eid);
}
dri3_flush_present_events(draw);
mtx_unlock(&draw->mtx);
-- 
2.17.0

On 4 May 2018 at 17:54, Mario Kleiner  wrote:
> On Fri, May 4, 2018 at 6:45 PM, Mike Lothian  wrote:
>> Hi
>>
>> The first hunk doesn't apply, the other 3 gives this with GCC 8.1
>>
>
> Oops, the perils of applying debug patches on top of debug patches...
>
> Can you add a...
>
> #include 
>
> at the top of the file, e.g, after '#include 
>
>  #include 
>  #include 
>  #include 
> -
> +#include 
>  #include 
>  #include 
>  #include 
>
> Then it should compile, albeit with some format warnings, but those
> shouldn't affect the outcome.
> -mario
>
>>
>> ../mesa-/src/loader/loader_dri3_helper.c: In function
>> ‘dri3_handle_present_event’:
>> ../mesa-/src/loader/loader_dri3_helper.c:376:13: error: implicit
>> declaration of function ‘printf’
>> [-Werror=implicit-function-declaration]
>>  printf("ORPHAN-C: %d x %d, drawable %d: recv %u vs send_sbc 
>> %lu\n",
>>  ^~
>> ../mesa-/src/loader/loader_dri3_helper.c:376:13: warning:
>> incompatible implicit declaration of built-in function ‘printf’
>> ../mesa-/src/loader/loader_dri3_helper.c:376:13: note: include
>> ‘’ or provide a declaration of ‘printf’
>> ../mesa-/src/loader/loader_dri3_helper.c:39:1:
>> +#include 
>>
>> ../mesa-/src/loader/loader_dri3_helper.c:376:13:
>>  printf("ORPHAN-C: %d x %d, drawable %d: recv %u vs send_sbc 
>> %lu\n",
>>  ^~
>> ../mesa-/src/loader/loader_dri3_helper.c:376:75: warning: format
>> ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has
>> type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
>>  printf("ORPHAN-C: %d x %d, drawable %d: recv %u vs send_sbc 
>> %lu\n",
>>  ~~^
>>  %llu
>> ../mesa-/src/loader/loader_dri3_helper.c:378:20:
>> draw->send_sbc);
>> ~~
>> ../mesa-/src/loader/loader_dri3_helper.c:430:10: warning:
>> incompatible implicit declaration of built-in function ‘printf’
>>   printf("ORPHAN-I: %d x %d, drawable %d: recv %u vs send_sbc %lu\n",
>>   ^~
>> ../mesa-/src/loader/loader_dri3_helper.c:430:10: note: include
>> ‘’ or provide a declaration of ‘printf’
>> ../mesa-/src/loa

Re: [Mesa-dev] [PATCH 2/2] loader_dri3: Variant 2: Wait for pending swaps to complete before drawable_fini.

2018-05-04 Thread Mario Kleiner
On Sat, May 5, 2018 at 4:08 AM, Mike Lothian  wrote:
> I definately saw the steam bug with patch 1 but not with plasmashell,
> I started seeing it with patch 2 but it seemed to fix itself
>

I had two hangs of kwin_x11 within the last 6 hours when alt-tabbing
between windows, where it got stuck in the
loader_dri3_swapbuffer_barrier() from patch 1/2. Not sure how that is
possible, or if the stacktrace was misleading, because i had to VT
switch to a text console to attach the debugger and this might be just
a side effect of that. But if it is true, then patch 1/2 would not be
it. Also 1/2 has a potential performance impact, whereas 2/2 doesn't.
However 2/2 would also need more work, as i can think of more complex
scenarios where it would filter the wrong events, although not in the
case of plasmashell or steam. Probably we'd need to sacrifice a few
sbc bits in the Present events serial field to transport a unique tag
for each incarnation of the loader_dri3_drawable, like a mini-hash of
the draw->eid. Ugly ugly...

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


Re: [Mesa-dev] [PATCH 2/2] loader_dri3: Variant 2: Wait for pending swaps to complete before drawable_fini.

2018-05-05 Thread Mike Lothian
Out of interest can you try running the vulkan smoketest, I'm seeing this:

smoketest
terminate called after throwing an instance of 'std::runtime_error'
 what():  VkResult -101004 returned
Aborted (core dumped)

On Sat, 5 May 2018 at 05:25 Mario Kleiner 
wrote:

> On Sat, May 5, 2018 at 4:08 AM, Mike Lothian  wrote:
> > I definately saw the steam bug with patch 1 but not with plasmashell,
> > I started seeing it with patch 2 but it seemed to fix itself
> >
>
> I had two hangs of kwin_x11 within the last 6 hours when alt-tabbing
> between windows, where it got stuck in the
> loader_dri3_swapbuffer_barrier() from patch 1/2. Not sure how that is
> possible, or if the stacktrace was misleading, because i had to VT
> switch to a text console to attach the debugger and this might be just
> a side effect of that. But if it is true, then patch 1/2 would not be
> it. Also 1/2 has a potential performance impact, whereas 2/2 doesn't.
> However 2/2 would also need more work, as i can think of more complex
> scenarios where it would filter the wrong events, although not in the
> case of plasmashell or steam. Probably we'd need to sacrifice a few
> sbc bits in the Present events serial field to transport a unique tag
> for each incarnation of the loader_dri3_drawable, like a mini-hash of
> the draw->eid. Ugly ugly...
>
> -mario
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] loader_dri3: Variant 2: Wait for pending swaps to complete before drawable_fini.

2018-05-05 Thread Mike Lothian
Which is:

VK_ERROR_OUT_OF_DATE_KHR = -101004,


On Sat, 5 May 2018 at 10:15 Mike Lothian  wrote:

> Out of interest can you try running the vulkan smoketest, I'm seeing this:
>
> smoketest
> terminate called after throwing an instance of 'std::runtime_error'
>  what():  VkResult -101004 returned
> Aborted (core dumped)
>
> On Sat, 5 May 2018 at 05:25 Mario Kleiner 
> wrote:
>
>> On Sat, May 5, 2018 at 4:08 AM, Mike Lothian  wrote:
>> > I definately saw the steam bug with patch 1 but not with plasmashell,
>> > I started seeing it with patch 2 but it seemed to fix itself
>> >
>>
>> I had two hangs of kwin_x11 within the last 6 hours when alt-tabbing
>> between windows, where it got stuck in the
>> loader_dri3_swapbuffer_barrier() from patch 1/2. Not sure how that is
>> possible, or if the stacktrace was misleading, because i had to VT
>> switch to a text console to attach the debugger and this might be just
>> a side effect of that. But if it is true, then patch 1/2 would not be
>> it. Also 1/2 has a potential performance impact, whereas 2/2 doesn't.
>> However 2/2 would also need more work, as i can think of more complex
>> scenarios where it would filter the wrong events, although not in the
>> case of plasmashell or steam. Probably we'd need to sacrifice a few
>> sbc bits in the Present events serial field to transport a unique tag
>> for each incarnation of the loader_dri3_drawable, like a mini-hash of
>> the draw->eid. Ugly ugly...
>>
>> -mario
>>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] loader_dri3: Variant 2: Wait for pending swaps to complete before drawable_fini.

2018-05-05 Thread Daniel Stone
On 5 May 2018 at 10:15, Mike Lothian  wrote:
> Out of interest can you try running the vulkan smoketest, I'm seeing this:
>
> smoketest
> terminate called after throwing an instance of 'std::runtime_error'
>  what():  VkResult -101004 returned
> Aborted (core dumped)

VK_ERROR_OUT_OF_DATE_KHR is returned from vkQueuePresentKHR when the
application _must_ recreate the swapchain it uses for rendering.
Usually this happens due to the window resizing (which the window
manager can do), which Vulkan apps _must_ handle themselves. The
smoketest chooses to handle this error by crashing.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] loader_dri3: Variant 2: Wait for pending swaps to complete before drawable_fini.

2018-05-05 Thread Mike Lothian
Thank you for the clarification.

On Sat, 5 May 2018 at 14:31 Daniel Stone  wrote:

> On 5 May 2018 at 10:15, Mike Lothian  wrote:
> > Out of interest can you try running the vulkan smoketest, I'm seeing
> this:
> >
> > smoketest
> > terminate called after throwing an instance of 'std::runtime_error'
> >  what():  VkResult -101004 returned
> > Aborted (core dumped)
>
> VK_ERROR_OUT_OF_DATE_KHR is returned from vkQueuePresentKHR when the
> application _must_ recreate the swapchain it uses for rendering.
> Usually this happens due to the window resizing (which the window
> manager can do), which Vulkan apps _must_ handle themselves. The
> smoketest chooses to handle this error by crashing.
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] loader_dri3: Variant 2: Wait for pending swaps to complete before drawable_fini.

2018-05-08 Thread Michel Dänzer
On 2018-05-05 06:25 AM, Mario Kleiner wrote:
> On Sat, May 5, 2018 at 4:08 AM, Mike Lothian  wrote:
>> I definately saw the steam bug with patch 1 but not with plasmashell,
>> I started seeing it with patch 2 but it seemed to fix itself
> 
> I had two hangs of kwin_x11 within the last 6 hours when alt-tabbing
> between windows, where it got stuck in the
> loader_dri3_swapbuffer_barrier() from patch 1/2. Not sure how that is
> possible, or if the stacktrace was misleading, because i had to VT
> switch to a text console to attach the debugger and this might be just
> a side effect of that. But if it is true, then patch 1/2 would not be
> it. Also 1/2 has a potential performance impact, whereas 2/2 doesn't.
> However 2/2 would also need more work, as i can think of more complex
> scenarios where it would filter the wrong events, although not in the
> case of plasmashell or steam. Probably we'd need to sacrifice a few
> sbc bits in the Present events serial field to transport a unique tag
> for each incarnation of the loader_dri3_drawable, like a mini-hash of
> the draw->eid. Ugly ugly...

How about the below?

Idle notify events shouldn't need special treatment, since the pixmap
XIDs of the buffers will be different between loader_dri3_drawable
incarnations, aren't they?


This still leaves the issue that the SBC moves backwards, which could
theoretically result in hangs with apps using glXWaitForSbcOML. Fixing
that would probably require changing the loader_dri3_drawable lifetime
cycle, which would probably be very invasive, if feasible at all. Maybe
we don't need to care about that for the time being, until there's a
real world app running into it.


diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index 6db8303d26d..f0ff2f07bde 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -370,9 +370,17 @@ dri3_handle_present_event(struct loader_dri3_drawable 
*draw,
* checking for wrap.
*/
   if (ce->kind == XCB_PRESENT_COMPLETE_KIND_PIXMAP) {
- draw->recv_sbc = (draw->send_sbc & 0xLL) | ce->serial;
- if (draw->recv_sbc > draw->send_sbc)
-draw->recv_sbc -= 0x1;
+ uint64_t recv_sbc = (draw->send_sbc & 0xLL) | 
ce->serial;
+
+ /* Only assume wraparound if that results in exactly the previous
+  * SBC + 1, otherwise ignore received SBC > sent SBC (those are
+  * probably from a previous loader_dri3_drawable instance) to avoid
+  * calculating bogus target MSC values in loader_dri3_swap_buffers_msc
+  */
+ if (recv_sbc <= draw->send_sbc)
+draw->recv_sbc = recv_sbc;
+ else if (recv_sbc == (draw->recv_sbc + 0x10001ULL))
+draw->recv_sbc = recv_sbc - 0x1ULL;

  /* When moving from flip to copy, we assume that we can allocate in
   * a more optimal way if we don't need to cater for the display


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] loader_dri3: Variant 2: Wait for pending swaps to complete before drawable_fini.

2018-05-09 Thread Adam Jackson
On Tue, 2018-05-08 at 11:42 +0200, Michel Dänzer wrote:

> Idle notify events shouldn't need special treatment, since the pixmap
> XIDs of the buffers will be different between loader_dri3_drawable
> incarnations, aren't they?

We're destroying loader_dri3_drawable structs at MakeCurrent time, but
not destroying actual drawables, so I don't think the XIDs will change.

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


Re: [Mesa-dev] [PATCH 2/2] loader_dri3: Variant 2: Wait for pending swaps to complete before drawable_fini.

2018-05-11 Thread Michel Dänzer
On 2018-05-09 07:32 PM, Adam Jackson wrote:
> On Tue, 2018-05-08 at 11:42 +0200, Michel Dänzer wrote:
> 
>> Idle notify events shouldn't need special treatment, since the pixmap
>> XIDs of the buffers will be different between loader_dri3_drawable
>> incarnations, aren't they?
> 
> We're destroying loader_dri3_drawable structs at MakeCurrent time, but
> not destroying actual drawables, so I don't think the XIDs will change.

I'm talking about loader_dri3_buffer::pixmap, which are destroyed in
loader_dri3_drawable_fini -> dri3_free_render_buffer.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev