I've been working on coding up the server and client side of
SGI_video_sync, OML_sync_control and SGI_swap_control.  I came up with
this set of new protocol (against the dri2-swapbuffers branch) to
support the new requests.

We still need to change the DRI2SwapBuffers request to handle the
various OML bits before it gets merged.

To summarize:
  DRI2GetMSCReq - get MSC triple
  DRI2WaitMSCReq - wait on an MSC count or divisor/remainder
  DRI2WaitSBCReq - wait on a swap count or all pending swaps
  DRI2MSCReply - MSC triple (generated in response to any of the above)

Kristian and I talked briefly about doing this client side using events
to notify clients when their CRTC changes, but there are a few issues:
  - races between client blocking and other server events (DPMS, window
    movement)
  - compositor interaction; in the compositor case the display server
    will be incrementing frame count based on compositor drawing rather
    than vblank events
so we thought a DRI2 solution was best here.  These particular calls
are expected to block frequently, so I don't think latency is as big a
concern as with some other operations (like SwapBuffers, but it also
has the second issue mentioned above, so needs to be server side).

Comments?  If these look ok I'll push them into the dri2-swapbuffers
branch and fix up DRI2SwapBuffers with the rest of the OML fields.

Thanks,
-- 
Jesse Barnes, Intel Open Source Technology Center

diff --git a/dri2proto.h b/dri2proto.h
index 37873c4..2fe7df5 100644
--- a/dri2proto.h
+++ b/dri2proto.h
@@ -50,6 +50,9 @@
 #define X_DRI2CopyRegion               6
 #define X_DRI2GetBuffersWithFormat     7
 #define X_DRI2SwapBuffers              8
+#define X_DRI2GetMSC                   9
+#define X_DRI2WaitMSC                  10
+#define X_DRI2WaitSBC                  11
 
 typedef struct {
     CARD32  attachment B32;
@@ -200,4 +203,50 @@ typedef struct {
 } xDRI2SwapBuffersReq;
 #define sz_xDRI2SwapBuffersReq   8
 
+typedef struct {
+    CARD8   reqType;
+    CARD8   dri2ReqType;
+    CARD16  length B16;
+    CARD32  drawable B32;
+} xDRI2GetMSCReq;
+#define sz_xDRI2GetMSCReq 8
+
+typedef struct {
+    CARD8   reqType;
+    CARD8   dri2ReqType;
+    CARD16  length B16;
+    CARD32  drawable B32;
+    CARD32  target_msc_hi B32;
+    CARD32  target_msc_lo B32;
+    CARD32  divisor_hi B32;
+    CARD32  divisor_lo B32;
+    CARD32  remainder_hi B32;
+    CARD32  remainder_lo B32;
+} xDRI2WaitMSCReq;
+#define sz_xDRI2WaitMSCReq 26
+
+typedef struct {
+    CARD8   reqType;
+    CARD8   dri2ReqType;
+    CARD16  length B16;
+    CARD32  drawable B32;
+    CARD32  target_sbc_hi B32;
+    CARD32  target_sbc_lo B32;
+} xDRI2WaitSBCReq;
+#define sz_xDRI2WaitSBCReq 16
+
+typedef struct {
+    CARD8   type;
+    CARD8   pad1;
+    CARD16  sequenceNumber B16;
+    CARD32  length B32;
+    CARD32  ust_hi B32;
+    CARD32  ust_lo B32;
+    CARD32  msc_hi B32;
+    CARD32  msc_lo B32;
+    CARD32  sbc_hi B32;
+    CARD32  sbc_lo B32;
+} xDRI2MSCReply;
+#define sz_xDRI2MSCReply 32
+
 #endif
diff --git a/dri2proto.txt b/dri2proto.txt
index 1bad3b9..f9cb8c9 100644
--- a/dri2proto.txt
+++ b/dri2proto.txt
@@ -110,6 +110,17 @@ of the front and back buffers.  If the display server 
supports it, this
 operation may be preferred, since it may be easier and/or more performant
 for the server to perform a simple buffer swap rather than a blit.
 
+2.6 Synchronizing rendering
+
+DRI2 provides several methods for synchronizing drawing with various events.
+The protocol for these methods is based on the SGI_video_sync and
+OML_sync_control OpenGL extensions.  Using the DRI2WaitMSC request, a client
+can wait for a specific frame count or divisor/remainder before continuing
+its processing.  With the DRI2WaitSBC request, clients can block until a given
+swap count is reached (as incremented by DRI2SwapBuffers).  Finally, using
+DRI2SwapBuffers, clients will be throttled to a frame interval specified by
+an earlier swap interval call (currently only available through GLX).
+
 
                             ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
 
@@ -309,6 +320,9 @@ The name of this extension is "DRI2".
        invalidate its render buffers after sending this request, causing
        a subsequent GetBuffers request to get updated buffer info.
 
+       This request is only available with protocol version 1.2 or
+       later.
+
 ┌───
     DRI2GetBuffersWithFormat
        drawable: DRAWABLE
@@ -334,6 +348,68 @@ The name of this extension is "DRI2".
        This request is only available with protocol version 1.1 or
        later.
 
+┌───
+    DRI2GetMSC
+       drawable: DRAWABLE
+      ▶
+       ust, msc, sbc: CARD64
+└───
+       Errors: Window
+
+       Get the current media stamp counter (MSC) and swap buffer count (SBC)
+       along with the unadjusted system time (UST) when the MSC was last
+       incremented.
+
+       This request is only available with protocol version 1.2 or
+       later.
+
+┌───
+    DRI2WaitMSC
+       drawable: DRAWABLE
+       target_msc: two CARD32s
+       divisor: two CARD32s
+       remainder: two CARD32s
+      ▶
+       ust, msc, sbc: CARD64
+└───
+       Errors: Window
+
+       Blocks the client until either the frame count reaches target_msc or,
+       if the frame count is already greater than target_msc when the request
+       is received, until the frame count % divisor = remainder.  If divisor
+       is 0, the client will be unblocked if the frame count is greater than
+       or equal to the target_msc.
+
+       Returns the current media stamp counter (MSC) and swap buffer count
+       (SBC) along with the unadjusted system time (UST) when the MSC was last
+       incremented.
+
+       This request is only available with protocol version 1.2 or
+       later.
+
+┌───
+    DRI2WaitSBC
+       drawable: DRAWABLE
+       target_sbc: two CARD32s
+      ▶
+       ust, msc, sbc: CARD64
+└───
+       Errors: Window
+
+       Blocks the client until the swap buffer count reaches target_sbc.  If
+       the swap buffer count is already greater than or equal to target_sbc
+       when the request is recieved, this request will return immediately.
+
+       If target_sbc is 0, this request will block the client until all
+       previous DRI2SwapBuffers requests have completed.
+
+       Returns the current media stamp counter (MSC) and swap buffer count
+       (SBC) along with the unadjusted system time (UST) when the MSC was last
+       incremented.
+
+       This request is only available with protocol version 1.2 or
+       later.
+
                             ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
 
 


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to