<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Yes,<br>
      <br>
      I assume divisor = 0.<br>
      <br>
      Initially the code was like that:<br>
      . if crtc_msc > target_msc, set target_msc to crtc_msc, and if
      PresentOptionAsync not requested, then increase target_msc.<br>
      . if ddx doing sync flips only, and we plan to do a flip, then
      decrease target_msc<br>
      . if target_msc was already reached, do a copy immediately (or
      async flip)<br>
      <br>
      Lets give as example a few scenarios:<br>
      the screen is currently at msc crtc_msc.<br>
      <br>
      Let's assume ddx is not able to do async flips:<br>
      <br>
      . Client presents for target_msc <= crtc_msc<br>
      -> target_msc set to crtc_msc<br>
      -> if Async not requested, target_msc increased by one<br>
      => We present immediately (copy) if Async requested<br>
      else if Async not requested:<br>
      -> if we plan to do a flip, we decrement target_msc (because
      sync flips delay effect by one msc)<br>
      -> if we don't plan to flip, we wait next vblank and copy then.<br>
      <br>
      <br>
      . Client presents for target_msc = crtc_msc + 1<br>
      -> PresentOptionAsync doesn't change anything<br>
      -> if doing flip then target_msc is decremented (same reason
      than before).<br>
      <br>
      In these two cases, when at the end of present_pixmap, we have
      target_msc = crtc_msc, then we are<br>
      in the case where we must copy immediately and won't be doing
      flip. That explains the "
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      target_msc > crtc_msc" check.<br>
      <br>
      I don't know if that system worked perfectly when ddx was async
      flips able.<br>
      I haven't checked yet if the new code is ok for sync flips.<br>
      <br>
      Yours,<br>
      <br>
      Axel<br>
      On 02/11/2015 09:56, Zhou, Jammy wrote :<br>
    </div>
    <blockquote
      cite="mid:FD5696F5CDD4B04D92C97DB96167DECA26534A18@SCYBEXDAG04.amd.com"
      type="cite">
      <pre wrap="">Thanks Axel. It is consistent with my understanding. 

For the 'pixmap' check in your previous change, it is used to differentiate present_pixmap and present_notify_msc, right? It looks like "target_msc >= crtc_msc" was used at the first place for present_pixmap, do you know the background about this?

Regards,
Jammy

-----Original Message-----
From: Axel Davy [<a class="moz-txt-link-freetext" href="mailto:axel.davy@ens.fr">mailto:axel.davy@ens.fr</a>] 
Sent: Monday, November 02, 2015 4:45 PM
To: Zhou, Jammy; Michel Dänzer
Cc: <a class="moz-txt-link-abbreviated" href="mailto:xorg-devel@lists.x.org">xorg-devel@lists.x.org</a>; Mario Kleiner
Subject: Re: [PATCH] present: Execute right away if target_msc equals current_msc

Hi,

As you can see here:
<a class="moz-txt-link-freetext" href="http://cgit.freedesktop.org/xorg/proto/presentproto/tree/presentproto.txt#n212">http://cgit.freedesktop.org/xorg/proto/presentproto/tree/presentproto.txt#n212</a>

It means to present immediately instead of waiting for the next vblank (if needed).

In practice when needed to present immediately, if the ddx is not able to do async flips, then we do a copy to the screen buffer, else we use that ability.

Yours,

Axel

On 02/11/2015 09:26, Zhou, Jammy wrote :
</pre>
      <blockquote type="cite">
        <pre wrap="">By the way, does PresentOptionAsync mean the same thing with the async flip capability in kernel side? Or is it just a flag to indicate X/DDX to do present immediately instead of waiting for the next vblank?

Regards,
Jammy

-----Original Message-----
From: Axel Davy [<a class="moz-txt-link-freetext" href="mailto:axel.davy@ens.fr">mailto:axel.davy@ens.fr</a>]
Sent: Thursday, October 29, 2015 3:42 PM
To: Michel Dänzer; Zhou, Jammy
Cc: <a class="moz-txt-link-abbreviated" href="mailto:xorg-devel@lists.x.org">xorg-devel@lists.x.org</a>; Mario Kleiner
Subject: Re: [PATCH] present: Execute right away if target_msc equals 
current_msc

Hi,

What is the current conscensus for how should PresentOptionAsync work ?

If I remember correctly, the semantic used to be:

. if we present at the current or past msc with the flag, two options:
-> if the ddx doesn't support async swap, we do copy to the screen
pixmap right away
-> if the ddx does support it, we do an async swap right away

. if we present at another msc, things behave as without PresentOptionAsync, that is we schedule a swap, and ask at msc-1 to the ddx to swap for msc.

With "Fix use of vsynced pageflips", I get the impression it shifted to:

. Async requested, but driver not having the async option -> do screen copy (no flips, whatever the msc) . if Async not requested and flip planned, present at msc-1, else at msc. (so for flips and Async flag, we do always plan to flip at msc ?
That means always tear, right ?)

That doesn't make a lot of sense to me, can someone clarify ?

I'm afraid this patch could be a workaround to currently broken behaviour, and not the correct fix.

I CCed Mario Kleiner.

Yours,

Axel Davy

On 29/10/2015 03:53, Michel Dänzer wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="">On 28.10.2015 19:39, Jammy Zhou wrote:
</pre>
          <blockquote type="cite">
            <pre wrap="">It is according to the protocol:

"If 'options' contains PresentOptionAsync, and the 'target-msc'
is less than or equal to the current msc for 'window', then the 
operation will be performed as soon as possible, not necessarily 
waiting for the next vertical blank interval."

Signed-off-by: Jammy Zhou <a class="moz-txt-link-rfc2396E" href="mailto:Jammy.Zhou@amd.com"><Jammy.Zhou@amd.com></a>
---
   present/present.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/present/present.c b/present/present.c index
beb4ff0..5900c22 100644
--- a/present/present.c
+++ b/present/present.c
@@ -871,7 +871,7 @@ present_pixmap(WindowPtr window,
   
       xorg_list_add(&vblank->event_queue, &present_exec_queue);
       vblank->queued = TRUE;
-    if ((pixmap && target_msc >= crtc_msc) || (!pixmap && target_msc > crtc_msc)) {
+    if (target_msc > crtc_msc) {
           ret = present_queue_vblank(screen, target_crtc, vblank->event_id, target_msc);
           if (ret == Success)
               return Success;

</pre>
          </blockquote>
          <pre wrap="">Looks good to me, but Cc'ing Axel Davy, who made the last change to 
this code.

Reviewed-by: Michel Dänzer <a class="moz-txt-link-rfc2396E" href="mailto:michel.daenzer@amd.com"><michel.daenzer@amd.com></a>


</pre>
        </blockquote>
      </blockquote>
      <pre wrap="">
</pre>
    </blockquote>
    <br>
  </body>
</html>